sugar-toolkit-gtk3/sugar/p2p/NotificationListener.py

20 lines
490 B
Python
Raw Normal View History

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:
def __init__(self, group, name):
service = group.get_service(name, Notifier.TYPE)
server = network.GroupServer(service.get_group_address(),
service.get_port(),
2006-05-15 20:48:08 +02:00
self._recv_multicast)
server.start()
self._listeners = {}
def add_listener(self, listener):
self._listeners.add(listener)
def _recv_multicast(self, msg):
for listener in self._listeners:
listener(msg)