Exemple #1
0
def calculator():
    global board, next_step
    while True:
        if isRunning:
            calc()
            commander.execute_command('board')
            time.sleep(delay)
Exemple #2
0
def listener():
    while True:
        m = raw_input()  # type: str
        m = m.strip()
        m = m.split(' ')  # type: list[str]
        commander.execute_command(*m)
        time.sleep(0.01)
def admin_user():
    while True:
        try:
            m = raw_input()
            m = m.split(' ')  # type: list[str]

            commander.execute_command(admin, *m)
        except Exception as e:
            import sys
            import traceback
            a = sys.exc_info()
            traceback.print_exception(*a)
            del a
thread.start_new_thread ( admin_user ,())

while True:
    sockets = [server_socket] + __unsigned__ + [user.socket for user in globals.users]
    rlist, wlist, xlist = select.select(sockets, sockets, sockets)  # type: tuple(list[socket.socket]
    r_server_socket, r_unsigned, r_users = split(*rlist)
    w_server_socket, w_unsigned, w_users = split(*wlist)
    x_server_socket, x_unsigned, x_users = split(*xlist)

    if r_server_socket is not None:
        sock, _ = r_server_socket.accept()  # type: socket.socket
        __unsigned__.append(sock)

    for sock in r_unsigned:

        m = sock.recv(1024)  # type: str
        m = m.strip()
        m = m.split(',')  # type: list[str]
        __unsigned__.remove(sock)
        m.insert(0, 'connect')
        commander.execute_command(sock, *m)
        # if len(globals.users) == 1:
        #     commander.execute_command(globals.users[0], 'create-room', 'test', '1234')

    for user in r_users:
        m = user.socket.recv(1024)  # type: str
        m = m.strip()
        # m = m[0:-1] # removing the '\n' in the end
        m = m.split(',')  # type: list[str]
        commander.execute_command(user, *m)