MCPcopy Create free account
hub / github.com/geekcomputers/Python / Client_Handler

Function Client_Handler

Python_chatting_application/server.py:13–34  ·  view source on GitHub ↗
(cli)

Source from the content-addressed store, hash-verified

11
12
13def Client_Handler(cli):
14 while True:
15 try:
16 reply = cli.recv(1024).decode("utf-8")
17 if reply == "QUIT":
18 index_of_cli = clients.index(cli)
19 nick = nickename[index_of_cli]
20 nickename.remove(nick)
21 clients.remove(cli)
22 BroadCasating(f"{nick} has left the chat room")
23 print(f"Disconnected with f{nick}")
24 break
25 BroadCasating(reply)
26 except Exception:
27 index_of_cli = clients.index(cli)
28 print(index_of_cli)
29 nick = nickename[index_of_cli]
30 nickename.remove(nick)
31 clients.remove(cli)
32 BroadCasating(f"{nick} has left the chat room")
33 print(f"Disconnected with {nick}")
34 break
35
36
37def BroadCasating(msg):

Callers

nothing calls this directly

Calls 3

BroadCasatingFunction · 0.85
indexMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected