2006-05-15 21:36:17 +02:00
|
|
|
from sugar.p2p.Notifier import Notifier
|
2006-05-15 20:48:08 +02:00
|
|
|
import network
|
|
|
|
|
|
|
|
class NotificationListener:
|
2006-06-16 20:20:09 +02:00
|
|
|
def __init__(self, service):
|
|
|
|
server = network.GroupServer(service.get_address(),
|
2006-05-15 21:03:05 +02:00
|
|
|
service.get_port(),
|
2006-05-15 20:48:08 +02:00
|
|
|
self._recv_multicast)
|
|
|
|
server.start()
|
|
|
|
|
2006-05-15 23:16:55 +02:00
|
|
|
self._listeners = []
|
2006-05-15 20:48:08 +02:00
|
|
|
|
|
|
|
def add_listener(self, listener):
|
2006-05-15 23:16:55 +02:00
|
|
|
self._listeners.append(listener)
|
2006-05-15 20:48:08 +02:00
|
|
|
|
|
|
|
def _recv_multicast(self, msg):
|
|
|
|
for listener in self._listeners:
|
|
|
|
listener(msg)
|