Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar/p2p
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2006-06-16 18:20:09 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-06-16 18:20:09 (GMT)
commit0cae557ab56cb82a30087e8abbc6bc82d118a995 (patch)
tree809f01b48d4a076e2d5fdff99fff69edc456df94 /sugar/p2p
parent5446b2509f8c542925aa24b2d822e32b2a83e077 (diff)
Register the model service and start working on
looking it up
Diffstat (limited to 'sugar/p2p')
-rw-r--r--sugar/p2p/NotificationListener.py5
-rw-r--r--sugar/p2p/Notifier.py11
-rw-r--r--sugar/p2p/model/LocalModel.py14
-rw-r--r--sugar/p2p/model/RemoteModel.py6
4 files changed, 14 insertions, 22 deletions
diff --git a/sugar/p2p/NotificationListener.py b/sugar/p2p/NotificationListener.py
index ba89936..433b777 100644
--- a/sugar/p2p/NotificationListener.py
+++ b/sugar/p2p/NotificationListener.py
@@ -2,9 +2,8 @@ from sugar.p2p.Notifier import Notifier
import network
class NotificationListener:
- def __init__(self, group, name):
- service = group.get_service(name, Notifier.TYPE)
- server = network.GroupServer(service.get_group_address(),
+ def __init__(self, service):
+ server = network.GroupServer(service.get_address(),
service.get_port(),
self._recv_multicast)
server.start()
diff --git a/sugar/p2p/Notifier.py b/sugar/p2p/Notifier.py
index 54ce735..2672f28 100644
--- a/sugar/p2p/Notifier.py
+++ b/sugar/p2p/Notifier.py
@@ -2,15 +2,8 @@ from sugar.p2p import network
from sugar.presence.Service import Service
class Notifier:
- TYPE = "_olpc_model_notification._udp"
- ADDRESS = "224.0.0.222"
- PORT = 6300
-
- def __init__(self, group, name):
- service = Service(name, Notifier.TYPE, Notifier.PORT, Notifier.ADDRESS)
- service.register(group)
-
- address = service.get_group_address()
+ def __init__(self, service):
+ address = service.get_address()
port = service.get_port()
self._client = network.GroupClient(address, port)
diff --git a/sugar/p2p/model/LocalModel.py b/sugar/p2p/model/LocalModel.py
index 7fb24a0..9d7046d 100644
--- a/sugar/p2p/model/LocalModel.py
+++ b/sugar/p2p/model/LocalModel.py
@@ -19,14 +19,15 @@ class LocalModel(AbstractModel):
SERVICE_TYPE = "_olpc_model._tcp"
SERVICE_PORT = 6300
- def __init__(self, pservice, model_id):
+ def __init__(self, activity, pservice, service):
AbstractModel.__init__(self)
self._pservice = pservice
- self._model_id = model_id
+ self._activity = activity
+ self._service = service
self._values = {}
self._setup_service()
- self._notifier = Notifier(group, model_id)
+ self._notifier = Notifier(service)
def get_value(self, key):
return self._values[key]
@@ -37,10 +38,9 @@ class LocalModel(AbstractModel):
self._notifier.notify(key)
def _setup_service(self):
- self._service = self._pservice.share_activity(self,
- stype=LocalModel.SERVICE_TYPE,
- '', port=LocalModel.PORT_TYPE
- properties=properties)
+ service = self._pservice.share_activity(self._activity,
+ stype = LocalModel.SERVICE_TYPE,
+ address = '', port = LocalModel.SERVICE_PORT)
self._setup_server(service)
# FIXME this is duplicated with StreamReader
diff --git a/sugar/p2p/model/RemoteModel.py b/sugar/p2p/model/RemoteModel.py
index a95c8c0..d11157a 100644
--- a/sugar/p2p/model/RemoteModel.py
+++ b/sugar/p2p/model/RemoteModel.py
@@ -4,11 +4,11 @@ from sugar.p2p.NotificationListener import NotificationListener
from sugar.p2p.model.AbstractModel import AbstractModel
class RemoteModel(AbstractModel):
- def __init__(self, group, service):
+ def __init__(self, service, notification_service):
AbstractModel.__init__(self)
self._service = service
- self._group = group
+ self._notification_service = notification_service
addr = "http://%s:%d" % (service.get_address(), service.get_port())
self._client = xmlrpclib.ServerProxy(addr)
@@ -23,5 +23,5 @@ class RemoteModel(AbstractModel):
def _setup_notification_listener(self):
name = self._service.get_name()
- self._notification = NotificationListener(self._group, name)
+ self._notification = NotificationListener(self._notification_service)
self._notification.add_listener(self._notify_model_change)