Esempio n. 1
0
 def userinfo_add(room_id, user, handler):
     if not key_exists(user):
         c_pipe.hset(user, "current_room", room_id)
         c_pipe.hset(user, "remote_ip", handler.request.remote_ip)
         c_pipe.hset(user, "login_datetime", time.strftime("%Y-%m-%d %H:%M"))
     else:
         c_pipe.hset(user, "current_room", room_id)
         c_pipe.hset(user, "remote_ip", handler.request.remote_ip)
         
     c_pipe.hset(user, "offline", "no")
     c_pipe.execute()
Esempio n. 2
0
def install_lobby_room():
    if not key_exists(lobby_room_key):
        c_pipe.hset(lobby_room_key, "room_id", lobby_room_id)
        c_pipe.hset(lobby_room_key, "room_magic_id", lobby_room_magic_id)
        c_pipe.hset(lobby_room_key, "room_name", lobby_room_name)
        c_pipe.hset(lobby_room_key, "room_max_user", lobby_room_max_user)
        c_pipe.hset(lobby_room_key, "room_cache_size", lobby_room_msg_cache_size)
        c_pipe.set(room_count_key, 2)
        c_pipe.execute()
        return True
    return False
Esempio n. 3
0
def install_default_room():
    if not key_exists(default_room_key):
        c_pipe.hset(default_room_key, "room_id", default_room_id)
        c_pipe.hset(default_room_key, "room_magic_id", default_room_magic_id)
        c_pipe.hset(default_room_key, "room_name", default_room_name)
        c_pipe.hset(default_room_key, "room_max_user", default_room_max_user)
        c_pipe.hset(default_room_key, "room_cache_size",
                    default_room_msg_cache_size)
        c_pipe.set(room_count_key, 1)
        c_pipe.execute()
        return True
    return False
Esempio n. 4
0
    def userinfo_add(room_id, user, handler):
        if not key_exists(user):
            c_pipe.hset(user, "current_room", room_id)
            c_pipe.hset(user, "remote_ip", handler.request.remote_ip)
            c_pipe.hset(user, "login_datetime",
                        time.strftime("%Y-%m-%d %H:%M"))
        else:
            c_pipe.hset(user, "current_room", room_id)
            c_pipe.hset(user, "remote_ip", handler.request.remote_ip)

        c_pipe.hset(user, "offline", "no")
        c_pipe.execute()
Esempio n. 5
0
            room_max_user = int(room_max_user)
        except Exception, e:
            LOG.info("the parameter 'room_max_user' is not a digest!")
            room_max_user = default_room_max_user
        else:
            if room_max_user > global_room_max_user:
                LOG.info("maximum user in chat room must less than 1000.")
                return False
        
        room_id = ChatroomManager.get_max_room_id() + 1
        c_pipe.hset(room_key, "room_id", room_id)
        c_pipe.hset(room_key, "room_magic_id", gen_uuid())
        c_pipe.hset(room_key, "room_name", room_name)
        c_pipe.hset(room_key, "room_max_user", room_max_user)
        c_pipe.hset(room_key, "room_cache_size", room_cache_size)
        c_pipe.execute()
        
        room_custom = dict(
            room_id = room_id,
            room_waiter_list = dict()
        )
        room_list.append(room_custom)
        
        c.getset(room_count_key, room_id)
        return room_id
    

class MessageCacheManager(object):
    def __init__(self):
        pass
Esempio n. 6
0
            room_max_user = int(room_max_user)
        except Exception, e:
            LOG.info("the parameter 'room_max_user' is not a digest!")
            room_max_user = default_room_max_user
        else:
            if room_max_user > global_room_max_user:
                LOG.info("maximum user in chat room must less than 1000.")
                return False

        room_id = ChatroomManager.get_max_room_id() + 1
        c_pipe.hset(room_key, "room_id", room_id)
        c_pipe.hset(room_key, "room_magic_id", gen_uuid())
        c_pipe.hset(room_key, "room_name", room_name)
        c_pipe.hset(room_key, "room_max_user", room_max_user)
        c_pipe.hset(room_key, "room_cache_size", room_cache_size)
        c_pipe.execute()

        room_custom = dict(room_id=room_id, room_waiter_list=dict())
        room_list.append(room_custom)

        c.getset(room_count_key, room_id)
        return room_id


class MessageCacheManager(object):
    def __init__(self):
        pass

    @staticmethod
    def get_room_cache_size(room_id):
        room_key = room_prefix + str(room_id)