Example #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)
Example #2
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))
Example #3
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)
Example #4
0
 def on_open_connection(self,connection):
     self._protected_send_raw_message("1::"+connection.get_route())
     session.Instance.on_open_connection(self,connection)