def _process(self, data, addr) : typestr, modelstr = data.strip().split(' ', 1) if typestr in self._conditions.keys() : self._conditions[typestr].acquire() self._conditions[typestr].notify_all() self._conditions[typestr].release() if typestr in self._subscriptions.keys() or '*' in self._subscriptions.keys() : model = Model.from_string(modelstr) instance = Event(typestr, model) if self._subscriptions.has_key('*') : callback = self._subscriptions['*'][0] args = self._subscriptions['*'][1] else : callback = self._subscriptions[typestr][0] args = self._subscriptions[typestr][1] if len(args) > 0 : callback(instance, args) else : callback(instance)
def __init__(self, model) : self._model = Model.from_string(model) self._name = self._model.get('name') self._api = API(self) self._api.get_event_channel().subscribe('MOVEACPT', self._on_move) self._position = self._model.get('position')