Exemple #1
0
def add_connected(c_id, room, client_e, client_n):
    c_id = str(c_id)
    room = str(room)
    c_client = ConnectedClient()
    c_client.client_id = c_id
    c_client.room = room
    c_client.e = client_e
    c_client.n = client_n
    c_client.connected = True
    c_client.put()

    mem_client = memcache.Client()
    while True:
        old_list = mem_client.gets(room, namespace="channels")
        if not old_list:
            old_list = list()
            old_list = ConnectedClient.query(ConnectedClient.room == room).fetch()
            mem_client.set(room, old_list, namespace="channels")

        old_list.append(c_client)
        if mem_client.cas(room, old_list, namespace="channels"):
            break