diff --git a/roboc/ConnectSocket.py b/roboc/ConnectSocket.py index 9fbe6b3..94654d3 100644 --- a/roboc/ConnectSocket.py +++ b/roboc/ConnectSocket.py @@ -43,6 +43,7 @@ class ConnectSocket: _BUFFER = 1024 # Template messages + _BROADCAST_MSG = "{}~ {}\n" _MSG_DISCONNECTED = "" _MSG_SALUTE = "Hi, {}, wait for other players\n" _MSG_SERVER_STOP = "Server stop" @@ -79,11 +80,13 @@ class ConnectSocket: def broadcast(self, sender, name, message): """ - Send message to all clients, except the sender + Send a message to all clients but the sender - In progress + :param obj sender: socket_object of tne sender + :param str name: name of tne sender + :param str message: message to send """ - message = "{}~ {}\n".format(name, message) + message = self._BROADCAST_MSG.format(name, message) for sckt in self._inputs: if sckt != self._CONNECTION and sckt != sender: try: diff --git a/roboc/todo.md b/roboc/todo.md index c11bf3b..591e950 100644 --- a/roboc/todo.md +++ b/roboc/todo.md @@ -19,6 +19,7 @@ - [ ] chat commands: listing players TODO15 - [ ] chat commands: chating with other players TODO16 - [ ] verify if user name is already used TODO17 +- [ ] rename ConnectSocket._user_name to ConnectSocket._user_name TODO18 - [ ] … TODO Ideas after correcting [exercice 3](https://openclassrooms.com/courses/apprenez-a-programmer-en-python/exercises/180):