This commit is contained in:
2020-03-29 13:52:36 +08:00
parent 2a15908935
commit 06bb6bd4cc
3 changed files with 15 additions and 6 deletions

View File

@@ -82,7 +82,7 @@ class Network_controller: # manage id and connection
def process_command(self, dp):
if dp.body == b'status':
print('Online %s' % self.id_dict)
print('Online %s' % str(list(self.id_dict.keys())))
def start_sending_dp(self):
@@ -145,7 +145,7 @@ class Network_controller: # manage id and connection
self.id_dict[id] = []
self.id_dict[id].append(connection)
self.all_connection_list.append(connection)
print('%s has connected' % id)
print('%s connected' % id)
def del_connection(self, id, connection):
@@ -172,7 +172,6 @@ class Connection:
self.thread_recv.start()
def _init(self): # init to check connection id, threading
err_code, flag = self.check_id()
if err_code:
@@ -264,8 +263,11 @@ class Connection:
'''
if self.positive:
self.send_id()
try:
data = self.conn.recv(BUFFSIZE)
except ConnectionResetError:
print('One connection failed before ID check')
data = self.conn.recv(BUFFSIZE)
if not data:
return 2, ''