Example #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()
Example #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()
Example #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()
Example #4
0
def sayhello(request):
    return json.dumps({'message':'Hello World'})
Example #5
0
def sayhello(request):
    return json.dumps({'message': 'Hello World'})