More fixes...
This commit is contained in:
parent
7300b8e429
commit
d2a0bd4d65
@ -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)
|
||||
|
@ -1,4 +1,3 @@
|
||||
from sugar.p2p.NotificationListener import NotificationListener
|
||||
from sugar.p2p import network
|
||||
from sugar.p2p.Service import Service
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user