You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
671 B
Python

18 years ago
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)