示例#1
0
    def on_close(self):

        r.zrem(self.chnl_key, self.current_user)
        users = r.zrange(self.chnl_key, 0, -1)

        chat = self.perform_user_list(users)

        self.waiters[self.chnl].remove(self)
        self.waiters.broadcast(self.chnl, chat)

        self.log('LEFT')
示例#2
0
    def open(self, *args, **kwargs):
        self.chnl = kwargs.get('channel', 'main')
        self.chnl_key = 'channels:{}:users'.format(self.chnl)

        count = int(r.zcount(self.chnl_key, 0, - 1))
        r.zadd(self.chnl_key, count+1, self.current_user)
        users = r.zrange(self.chnl_key, 0, -1)

        chat = self.perform_user_list(users)

        self.waiters[self.chnl].add(self)
        self.waiters.broadcast(self.chnl, chat)

        self.log('JOINED')