From 2f024b5d0a3ea45db780b2e3e2903119ad18e174 Mon Sep 17 00:00:00 2001 From: Fred Z Date: Fri, 9 Mar 2018 00:01:54 +0100 Subject: [PATCH] count_client(): use client with a filled username --- roboc/ConnectSocket.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/roboc/ConnectSocket.py b/roboc/ConnectSocket.py index b53cc1f..9fbe6b3 100644 --- a/roboc/ConnectSocket.py +++ b/roboc/ConnectSocket.py @@ -109,8 +109,15 @@ class ConnectSocket: print(self._MSG_SERVER_STOP) def count_clients(self): - """ Count connected clients""" - return len(self._inputs) - 1 + """ + Count connected and named clients + + (to avoid playing with a unamed player) + """ + connect = 1 # the 1st entry is the main connection + unnamed = self._user_name.count(False) # unnamed clients + total = len(self._user_name) # All sockets + return total - unnamed - connect def list_sockets(self, print_it=True): """ List connected sckts """