Exemple #1
0
def broadcast(cid, to_others, to_host = None, additional_channels = set(), event='message'):
   # all clients that are listening to channel cid
   clients = listening_clients(cid).union(additional_channels)
   pipe = red.pipeline()
   for c in clients:
      if int(c) == int(cid):
         if to_host is not None:
            pipe.publish('sse-%s' % cid, u'%s;%s' % (event, json.dumps(to_host)))
      else:
         pipe.publish('sse-%s' % c, u'%s;%s' % (event, json.dumps(to_others)))
   pipe.execute()
Exemple #2
0
def notify(things, event='message'):
   pipe = red.pipeline()
   for channel, message in things.items():
      pipe.publish('sse-%s' % channel, u'%s;%s' % (event, json.dumps(message)))
   pipe.execute()