Esempio n. 1
0
def send_account_info(dest_sock, username_length):
    username_length = int(username_length)
    username = dest_sock.recv(username_length)

    user = User(username)
    if user.exists():
        user.by_file()
        msg = (user.get_info())
        log("Sent user info of user " + username)

    answers_queue.append(Answer(dest_sock, Answer.ACC_TYPE, len(msg), msg))

    if dest_sock not in outputs:
        outputs.append(dest_sock)
    inputs.remove(dest_sock)
Esempio n. 2
0
def send_login_msg(dest_sock, data_len):
    data_len = int(data_len)
    username = dest_sock.recv(data_len)

    usr = User(username)
    if usr.exists():
        usr.by_file()
        msg = "Welcome back " + username
        log("User logged in : " + username)
    else:
        usr.new_user()
        log("User created : " + username)
        msg = "Welcome aboard " + username

    answers_queue.append(Answer(dest_sock, Answer.LOG_TYPE, len(msg), msg))

    if dest_sock not in outputs:
        outputs.append(dest_sock)
    inputs.remove(dest_sock)