vegbesserungen
This commit is contained in:
parent
11396ef2cf
commit
a3197dbc28
2 changed files with 8 additions and 3 deletions
|
@ -14,12 +14,14 @@ if nickname == "":
|
||||||
run = True
|
run = True
|
||||||
|
|
||||||
def receive_message(sock):
|
def receive_message(sock):
|
||||||
|
print_lock = threading.Lock()
|
||||||
while run:
|
while run:
|
||||||
try:
|
try:
|
||||||
msg = sock.recv(1024).decode('utf-8')
|
msg = sock.recv(1024).decode('utf-8')
|
||||||
if not msg:
|
if not msg:
|
||||||
break
|
break
|
||||||
print(f"\r{msg}\n", end='', flush=True)
|
with print_lock:
|
||||||
|
print(f"\r{msg}\n", end='', flush=True)
|
||||||
except:
|
except:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,11 @@ def send_to_all(conn, msg):
|
||||||
try:
|
try:
|
||||||
client.sendall(msg.encode('utf-8'))
|
client.sendall(msg.encode('utf-8'))
|
||||||
except BrokenPipeError:
|
except BrokenPipeError:
|
||||||
print("Broken Pipe Error")
|
print("Verbindung verloren.")
|
||||||
pass
|
with lock:
|
||||||
|
clients.remove((conn, nick))
|
||||||
|
conn.close()
|
||||||
|
break
|
||||||
|
|
||||||
def handle_client(conn, addr):
|
def handle_client(conn, addr):
|
||||||
nick = conn.recv(1024).decode('utf-8')
|
nick = conn.recv(1024).decode('utf-8')
|
||||||
|
|
Loading…
Reference in a new issue