2006-05-15 21:03:05 +02:00
|
|
|
from sugar.p2p import network
|
2006-05-15 21:12:08 +02:00
|
|
|
from sugar.p2p.Service import Service
|
2006-05-15 20:48:08 +02:00
|
|
|
|
|
|
|
class Notifier:
|
2006-05-15 21:03:05 +02:00
|
|
|
TYPE = "_olpc_model_notification._udp"
|
|
|
|
ADDRESS = "224.0.0.222"
|
|
|
|
PORT = 6300
|
|
|
|
|
2006-05-15 20:48:08 +02:00
|
|
|
def __init__(self, group, name):
|
2006-05-15 22:28:09 +02:00
|
|
|
service = Service(name, Notifier.TYPE, Notifier.PORT, Notifier.ADDRESS)
|
2006-05-15 21:03:05 +02:00
|
|
|
service.register(group)
|
|
|
|
|
2006-05-15 22:57:23 +02:00
|
|
|
address = service.get_group_address()
|
2006-05-15 20:48:08 +02:00
|
|
|
port = service.get_port()
|
|
|
|
self._client = network.GroupClient(address, port)
|
|
|
|
|
|
|
|
def notify(self, msg):
|
|
|
|
self._client.send_msg(msg)
|