blob: e490f39049dffccfe7ebef9508dfd215e74ef869 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
from Service import Service
import network
class NotificationListener:
TYPE = "_olpc_model_notification._udp"
ADDRESS = "224.0.0.222"
PORT = 6300
def __init__(self, group, name):
server = network.GroupServer(NotificationListener.TYPE,
NotificationListener.PORT,
self._recv_multicast)
server.start()
service = Service(name, NotificationListener.TYPE,
NotificationListener.ADDRESS,
NotificationListener.PORT, True)
service.register(group)
self._listeners = {}
def add_listener(self, listener):
self._listeners.add(listener)
def _recv_multicast(self, msg):
for listener in self._listeners:
listener(msg)
|