X-Git-Url: http://git.maemo.org/git/?p=jamaendo;a=blobdiff_plain;f=jamaui%2Fpostoffice.py;h=9453176f4b0adbab72afa7f27c7e641e5a8af7ff;hp=675f9bffa7c9e8e14e1f2bc34fb885bfc966ddf1;hb=19020e8dae378875c8bfcd7e573ca5e91b1dfa10;hpb=44b759cfcfb80d94ddac5ea11302a6f94cb307b4 diff --git a/jamaui/postoffice.py b/jamaui/postoffice.py index 675f9bf..9453176 100644 --- a/jamaui/postoffice.py +++ b/jamaui/postoffice.py @@ -35,26 +35,24 @@ class PostOffice(object): def notify(self, tag, *data): clients = self.tags.get(tag) if clients: - log.debug("(%s %s) -> [%s]", - tag, - " ".join(str(x) for x in data), - " ".join(str(x) for x in clients)) - for client in clients: + #log.debug("(%s %s) -> [%s]", + # tag, + # " ".join(str(x) for x in data), + # " ".join(repr(x) for x,_ in clients)) + for ref, client in clients: client(*data) - def connect(self, tag, callback): + def connect(self, tag, ref, callback): if tag not in self.tags: self.tags[tag] = [] clients = self.tags[tag] if callback not in clients: - clients.append(callback) + clients.append((ref, callback)) - def disconnect(self, tag, callback): + def disconnect(self, tag, ref): if tag not in self.tags: self.tags[tag] = [] - clients = self.tags[tag] - if callback in clients: - clients.remove(callback) + self.tags[tag] = [(_ref, cb) for _ref, cb in self.tags[tag] if _ref != ref] postoffice = PostOffice()