Use random port for local models, clean up some model code, and don't double-register models when we hear our own announcement
This commit is contained in:
parent
7e50e0c8a1
commit
db90d4a209
@ -44,7 +44,7 @@ class BrowserActivity(Activity):
|
|||||||
if self._mode != BrowserActivity.LEADING:
|
if self._mode != BrowserActivity.LEADING:
|
||||||
self._model_service = service
|
self._model_service = service
|
||||||
|
|
||||||
if self._notif_service and self._model_service:
|
if not self._model and self._notif_service and self._model_service:
|
||||||
self._model = RemoteModel(self._model_service, self._notif_service)
|
self._model = RemoteModel(self._model_service, self._notif_service)
|
||||||
self._model.add_listener(self.__shared_location_changed_cb)
|
self._model.add_listener(self.__shared_location_changed_cb)
|
||||||
|
|
||||||
@ -58,7 +58,6 @@ class BrowserActivity(Activity):
|
|||||||
self._model.set_value('title', title)
|
self._model.set_value('title', title)
|
||||||
|
|
||||||
def __notif_bar_action_cb(self, bar, action_id):
|
def __notif_bar_action_cb(self, bar, action_id):
|
||||||
print action_id
|
|
||||||
if action_id == 'set_shared_location':
|
if action_id == 'set_shared_location':
|
||||||
self._update_shared_location()
|
self._update_shared_location()
|
||||||
elif action_id == 'goto_shared_location':
|
elif action_id == 'goto_shared_location':
|
||||||
|
@ -17,7 +17,6 @@ class ModelRequestHandler(object):
|
|||||||
|
|
||||||
class LocalModel(AbstractModel):
|
class LocalModel(AbstractModel):
|
||||||
SERVICE_TYPE = "_olpc_model._tcp"
|
SERVICE_TYPE = "_olpc_model._tcp"
|
||||||
SERVICE_PORT = 6300
|
|
||||||
|
|
||||||
def __init__(self, activity, pservice, service):
|
def __init__(self, activity, pservice, service):
|
||||||
AbstractModel.__init__(self)
|
AbstractModel.__init__(self)
|
||||||
@ -40,7 +39,7 @@ class LocalModel(AbstractModel):
|
|||||||
def _setup_service(self):
|
def _setup_service(self):
|
||||||
service = self._pservice.share_activity(self._activity,
|
service = self._pservice.share_activity(self._activity,
|
||||||
stype = LocalModel.SERVICE_TYPE,
|
stype = LocalModel.SERVICE_TYPE,
|
||||||
address = '', port = LocalModel.SERVICE_PORT)
|
address = '')
|
||||||
self._setup_server(service)
|
self._setup_server(service)
|
||||||
|
|
||||||
# FIXME this is duplicated with StreamReader
|
# FIXME this is duplicated with StreamReader
|
||||||
|
@ -24,6 +24,5 @@ class RemoteModel(AbstractModel):
|
|||||||
self._client.set_value(key, value)
|
self._client.set_value(key, value)
|
||||||
|
|
||||||
def _setup_notification_listener(self):
|
def _setup_notification_listener(self):
|
||||||
name = self._service.get_name()
|
|
||||||
self._notification = NotificationListener(self._notification_service)
|
self._notification = NotificationListener(self._notification_service)
|
||||||
self._notification.add_listener(self._notify_model_change)
|
self._notification.add_listener(self._notify_model_change)
|
||||||
|
Loading…
Reference in New Issue
Block a user