diff --git a/chat/TODO.md b/chat/TODO.md index ba21008..dcfc1e5 100644 --- a/chat/TODO.md +++ b/chat/TODO.md @@ -8,8 +8,8 @@ - [x] ~~crash after 2 in client~~ - [x] ~~sending welcome message only at 1st client connection FIX #20~~ - [x] ~~client freeze when sending empty string or spaces~~ +- [x] ~~move closing connection at the script's end~~ - [ ] asking/using client-nickname - [ ] clean the prompt and std.out a bit messy since broadcasting -- [ ] move closing connection at the script's end - [ ] using wlist with select.select for hardening the script - [ ] … diff --git a/chat/server.py b/chat/server.py index 96eddc4..2650b3e 100755 --- a/chat/server.py +++ b/chat/server.py @@ -71,24 +71,13 @@ while 1: socket_object.send(MSG_WELCOME) else: # receiving data - try: - data = socket.recv(BUFFER).decode().strip() - if data.upper() == "QUIT": - print(MSG_CLIENT_DISCONNECTED.format(socket.getpeername())) - broadcast(socket, MSG_DISCONNECTED) - inputs.remove(socket) - socket.close() - continue - - elif data: - print(MSG_CLIENT_ID.format(socket.getpeername(), data)) - broadcast(socket, data) - except Exception as except_detail: - print("Exception: «{}»".format(except_detail)) + data = socket.recv(BUFFER).decode().strip() + if data.upper() == "QUIT": print(MSG_CLIENT_DISCONNECTED.format(socket.getpeername())) - import pdb; pdb.set_trace() + broadcast(socket, MSG_DISCONNECTED) inputs.remove(socket) socket.close() - continue -MAIN_CONNECTION.close() + elif data: + print(MSG_CLIENT_ID.format(socket.getpeername(), data)) + broadcast(socket, data)