示例#1
0
 def add(self, data):
     try:
         json_obj = json.loads(data)
         token = Token()
         if token.get_data(json_obj['token'], json_obj['data']['channel']):
             self.logger.debug('django-sockjs-server:Subscrbe to channel %s' % json_obj['data']['channel'])
             self.conn.subscribe_list.add(json_obj['data']['channel'])
             self.conn.pika_client.add_subscriber_channel(json_obj['data']['channel'], self.conn)
     except (KeyError, TypeError):
         pass
示例#2
0
 def add(self, data):
     try:
         json_obj = json.loads(data)
         token = Token()
         self._compat_transform(json_obj)
         if token.get_data(json_obj['token'], json_obj['data']['room']):
             #uid = self._generate_id(json_obj)
             host = self.get_host()
             room = json_obj['data']['room']
             uid = self.conn.id
             self.conn.sockjs_server.add_subscriber_room(room, self.conn)
             self.logger.debug(
                 'django-sockjs-server (Subscribe): Subscribe to channel %s'
                 % room)
             self.redis.lpush(room, json.dumps({'host': host, 'id': uid}))
     except (KeyError, TypeError):
         pass
示例#3
0
 def add(self, data):
     try:
         json_obj = json.loads(data)
         token = Token()
         self._compat_transform(json_obj)
         if token.get_data(json_obj['token'], json_obj['data']['room']):
             #uid = self._generate_id(json_obj)
             host = self.get_host()
             room = json_obj['data']['room']
             uid = self.conn.id
             self.conn.sockjs_server.add_subscriber_room(
                 room, self.conn
             )
             self.logger.debug(
                 'django-sockjs-server (Subscribe): Subscribe to channel %s' % room
             )
             self.redis.lpush(
                 room,
                 json.dumps({'host': host, 'id': uid})
             )
     except (KeyError, TypeError):
         pass
    def add(self, data):
        try:
            json_obj = json.loads(data)
            token = Token()
            if token.get_data(json_obj['token'], json_obj['data']['channel']):
                uid = self._generate_id(json_obj)
                host = self.get_host()
                room = json_obj['data']['channel']
                self.logger.debug(
                    'django-sockjs-server:Subscrbe to channel %s' %
                    json_obj['data']['channel'])

                self.redis.lpush(json_obj['data']['channel'],
                                 json.dumps({
                                     'host': host,
                                     'id': uid
                                 }))

                self.conn.subscribe_list.add(uid)
                self.conn.pika_client.add_subscriber_channel(
                    uid, room, self.conn)

        except (KeyError, TypeError):
            pass
def sockjs_auth_token(room_name, unq_id=None):
    token = Token()
    if unq_id:
        return token.get_secret_data(room_name+str(unq_id))
    return token.get_secret_data(room_name)
示例#6
0
 def gen_c_token(self, channel):
     token = Token()
     c_token = token.get_secret_data(channel)
     self.redis.set(c_token, channel)
     return c_token