Beispiel #1
0
 def send(self, data):
     client = OrbitedClient()
     if hasattr(settings, 'ORBITED_DISPATCH_PORT'):
         client.port = int(settings.ORBITED_DISPATCH_PORT)
     client.connect()
     recipient = self.get_recipient()
     body = {'channel': self.channel, 'body': data}
     response = client.event([recipient], body)
     client.disconnect()
     return response
Beispiel #2
0
 def send(self, data, channel):
     """Send message to all users suscribed to a channel
     """
     clients = Client.objects.filter(channel=channel)
     recipients = []
     for client in clients:
         recipients.append(client.get_recipient())
     client = OrbitedClient()
     if hasattr(settings, 'ORBITED_DISPATCH_PORT'):
         client.port = int(settings.ORBITED_DISPATCH_PORT)
     client.connect()
     body = {'channel': channel, 'body': data}
     response = client.event(recipients, body)
     client.disconnect()
     return response