From d2a0bd4d65f5cc9b757735a29d18d54d345e9269 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Mon, 15 May 2006 15:36:17 -0400 Subject: [PATCH] More fixes... --- sugar/p2p/NotificationListener.py | 4 ++++ sugar/p2p/Notifier.py | 1 - sugar/p2p/Service.py | 3 ++- sugar/p2p/model/RemoteModel.py | 3 ++- sugar/p2p/model/Store.py | 2 +- sugar/p2p/presence.py | 2 +- 6 files changed, 10 insertions(+), 5 deletions(-) diff --git a/sugar/p2p/NotificationListener.py b/sugar/p2p/NotificationListener.py index 4fe742da..13ee4736 100644 --- a/sugar/p2p/NotificationListener.py +++ b/sugar/p2p/NotificationListener.py @@ -1,9 +1,12 @@ from Service import Service +from sugar.p2p.Notifier import Notifier import network class NotificationListener: def __init__(self, group, name): service = group.get_service(name, Notifier.TYPE) + print service.get_address() + print service.get_port() server = network.GroupServer(service.get_address(), service.get_port(), self._recv_multicast) @@ -15,5 +18,6 @@ class NotificationListener: self._listeners.add(listener) def _recv_multicast(self, msg): + print 'Got message ' + msg for listener in self._listeners: listener(msg) diff --git a/sugar/p2p/Notifier.py b/sugar/p2p/Notifier.py index ae366e96..e4d3847c 100644 --- a/sugar/p2p/Notifier.py +++ b/sugar/p2p/Notifier.py @@ -1,4 +1,3 @@ -from sugar.p2p.NotificationListener import NotificationListener from sugar.p2p import network from sugar.p2p.Service import Service diff --git a/sugar/p2p/Service.py b/sugar/p2p/Service.py index 50bbf86c..9371b05e 100644 --- a/sugar/p2p/Service.py +++ b/sugar/p2p/Service.py @@ -28,4 +28,5 @@ class Service(object): def register(self, group): pannounce = presence.PresenceAnnounce() - pannounce.register_service(self._name, self._port, self._stype) + pannounce.register_service(self._address, self._name, + self._port, self._stype) diff --git a/sugar/p2p/model/RemoteModel.py b/sugar/p2p/model/RemoteModel.py index b966b435..a95c8c0f 100644 --- a/sugar/p2p/model/RemoteModel.py +++ b/sugar/p2p/model/RemoteModel.py @@ -4,10 +4,11 @@ from sugar.p2p.NotificationListener import NotificationListener from sugar.p2p.model.AbstractModel import AbstractModel class RemoteModel(AbstractModel): - def __init__(self, service): + def __init__(self, group, service): AbstractModel.__init__(self) self._service = service + self._group = group addr = "http://%s:%d" % (service.get_address(), service.get_port()) self._client = xmlrpclib.ServerProxy(addr) diff --git a/sugar/p2p/model/Store.py b/sugar/p2p/model/Store.py index d39783f4..8a694440 100644 --- a/sugar/p2p/model/Store.py +++ b/sugar/p2p/model/Store.py @@ -17,6 +17,6 @@ class Store: else: service = self._group.get_service(model_id, LocalModel.SERVICE_TYPE) if service: - return RemoteModel(service) + return RemoteModel(self._group, service) else: return None diff --git a/sugar/p2p/presence.py b/sugar/p2p/presence.py index 4c5c086f..4edfc38c 100644 --- a/sugar/p2p/presence.py +++ b/sugar/p2p/presence.py @@ -77,7 +77,7 @@ class PresenceAnnounce(object): self.server = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, avahi.DBUS_PATH_SERVER), avahi.DBUS_INTERFACE_SERVER) self._hostname = None - def register_service(self, rs_name, rs_port, rs_service, **kwargs): + def register_service(self, rs_address, rs_name, rs_port, rs_service, **kwargs): g = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, self.server.EntryGroupNew()), avahi.DBUS_INTERFACE_ENTRY_GROUP) if rs_name is None: if self._hostname is None: