Ejemplo n.º 1
0
 def broadcast(self, channel, data):
     """
     Emit the given message to all connected users.
     """
     path = '/emit/broadcast/%s' % (channel)
     headers = {'Content-Type': 'application/json'}
     data = json.dumps(data)
     response = self._do_request('POST', path, data, headers)
     response.read()
Ejemplo n.º 2
0
 def broadcast_room(self, channel, data):
     """
     Emitts the message over the specified channel to all members
     of the group.
     """
     path = '/emit/room/%s' % (channel)
     headers = {'Content-Type': 'application/json'}
     data = json.dumps(data)
     response = self._do_request('POST', path, data, headers)
     response.read()
Ejemplo n.º 3
0
 def emit(self, user_id, channel, data):
     """
     send a message over the given channel to the specified user.
     `data` should be a regular python dict, or any other object
     that is json.dumps'able.
     """
     path = '/emit/user/%s/%s' % (user_id, channel)
     headers = {'Content-Type': 'application/json'}
     data = json.dumps(data)
     response = self._do_request('POST', path, data, headers)
     response.read()
Ejemplo n.º 4
0
def sayhello(request):
    return json.dumps({'message':'Hello World'})
Ejemplo n.º 5
0
def sayhello(request):
    return json.dumps({'message': 'Hello World'})