示例#1
0
 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)
示例#2
0
 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)
示例#3
0
 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))
示例#4
0
 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()
示例#5
0
 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)
示例#6
0
 def send_raw_message(self,message):
     self.write(
         '<script>_(%s);</script>' % json.dumps(message)
     )
     self.flush()
示例#7
0
 def send_raw_message(self,message):
     self.write(
                 'data: %s\r\n\r\n' % json.dumps(message)
             )
     self.flush()