3 class PostOffice(object):
7 def has_tag(self, tag):
8 return tag in self.tags
9 def notify(self, tags, data):
11 cb = self.tags.get(tag)
14 def register(self, tag, callback):
15 self.tags[tag] = callback
20 def notify(self, tags, data):
21 if not isinstance(tags, list):
23 for client in clients:
24 client.notify(tags, data)
26 def register(self, client_id, tag, callback):
27 client = self.clients.get(client_id)
30 self.clients[client_id] = client
31 client.register(tag, callback)
33 postoffice = PostOffice()