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