Adds `server_log()` method in order to export the `print()` calls.
Centralize _log_, _broadcast_ & _send_ operations in the bottom of the
loop (except when sockets needs to be close).
I think it is improves readability and will facilitate code evolution,
for example when writing the servers log in file(s).
Now sends messages only to named-client, and for that uses
`list_sockets()`
Takes sender name from `_user_name` attribute and delete the name
argument from the method
`list_sockets()` uses only clients with a name already typed in
(filled in `_user_name` attribute), to avoid starting a game with not
named player
`count_clients()` was too messy and autonomous, now it uses
`list_sockets()` for counting only named players and not depend on
naming player mechanism or main socket.# Veuillez saisir le message de
validation pour vos modifications. Les lignes
Traceback (most recent call last):
File "server.py", line 78, in <module>
peername = socket.getpeername()
OSError: [Errno 107] Transport endpoint is not connected
- convert logic to oreiented object
- server crash witn opened connection with <ctrl+Z>
- add some commands: help, list user, disconnect user, etc
- add time logging:
- a timestamp in log's server
- brodcast time to client at regular intervals
- UPDATE: last condition for messages passing the commands case and
the string.stripping()
- FIX: clean the prompt and std.out a bit messy since broadcasting
Remove:
- try/catch for received case, seems to be useless
- useless `continue`
- **move closing connection at the script's end** from TODO, do not find how to exit while from handler()
I do not know if the bug disappear or if the bug has never existed.
The messaqe is striped so, nothing is sent when it contains nothing
or only spaces.
Under heavy charge the script might be weak with seocket.read() &
socket.send() using together rlist in select.select().
See https://pymotw.com/3/select/index.html
Add clean server disconnection with «quit» keyword
Fix this 2 bugs:
- show message on server when client use <ctrl+c>
- crash after 2 <ctrl+c> in client
Now it's a chat-room, each message sending by a client is now
broadcasted to other clients.
Modifications on the client are:
- rename connections list as in server.py
- fix using the wrong list for checking events. It was not a problem
before implementation of broadcasting