def send_ack(self,connection, id,data=None): msg = "6::%s:%s" % (connection.get_route(), id) if data: if not isinstance(data,list): data = [data] msg+="+" + json.dumps(data) self._protected_send_raw_message(msg)
def send_raw_message(self, message): num = self._index if num is None: raise HTTPError(403, "Index not specified!") message = "io.j[%s](%s);" % (num, json.dumps(message)) self.set_header("X-XSS-Protection", "0") self.set_header("Connection", "Keep-Alive") super(Handler, self).send_raw_message(message)
def send_message(self, connection, message, callback=None): type = 3 if not isinstance(message,basestring): type = 4 message = json.dumps(message) msg_id = "" if callback: msg_id = self.queue_ack(connection,callback) self._protected_send_raw_message("%i:%s:%s:%s" % (type, msg_id, connection.get_route(), message))
def send_raw_message(self, message): num = self._index if num is not None: self.set_header('Content-Type', 'text/javascript; charset=UTF-8') message = 'io.j[%s](%s);' % (num, json.dumps(message)) else: self.set_header('Content-Type', 'text/plain; charset=UTF-8') self.set_header('Content-Length', len(message)) self.write(message) self.finish()
def emit_event(self, connection, name, args, callback=None): msg_id = "" if callback: msg_id = self.queue_ack(connection, callback) + "+" event = { 'name' : name, 'args' : args } msg = "5:%s:%s:%s" % (msg_id, connection.get_route(), json.dumps(event)) self._protected_send_raw_message(msg)
def send_raw_message(self,message): self.write( '<script>_(%s);</script>' % json.dumps(message) ) self.flush()
def send_raw_message(self,message): self.write( 'data: %s\r\n\r\n' % json.dumps(message) ) self.flush()