Commit Graph

7 Commits

Author SHA1 Message Date
Fred Z
a14ef683cb Export template's message from server_log()
In order to use this method in the whole class.
Update `__init__()` & `close()` to use `server_log()`. NO MORE `print()`
in this class ;-)
2018-03-14 10:40:19 +01:00
Fred Z
703380ded6 Refactors listen() about log, broadcast & send
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).
2018-03-14 10:40:19 +01:00
Fred Z
f90a1a38d5 Refuses client connection beyond a certain number
FIX TODO19: add max player number
2018-03-14 10:40:19 +01:00
Fred Z
7708781e29 Checks player name in listen()
Adds length limit
Fix TODO17: verify if user name is already used
2018-03-14 10:40:19 +01:00
Fred Z
c075c17172 Improves broadcast(): linked to list_sockets()
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
2018-03-14 10:40:19 +01:00
Fred Z
1c5366beb5 Refactors count_clients() & list_sockets()
`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
2018-03-14 10:40:18 +01:00
Fred Z
c7096ee757 Export Map instanciation in parent script
More readable and easier for adding multiplayer feature in the Map object
2018-03-14 10:40:18 +01:00