mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2026-01-04 15:49:57 +01:00
improve client isConnected method
This commit is contained in:
parent
361afe2ff1
commit
3cd5a59bb5
|
|
@ -105,13 +105,7 @@ class TCPClient:
|
|||
@property
|
||||
def isConnected(self):
|
||||
"""!Property of client connected state"""
|
||||
try:
|
||||
aliveMsg = "<alive>"
|
||||
header = str(len(aliveMsg)).ljust(HEADERSIZE)
|
||||
self._sock.sendall(bytes(header + aliveMsg, "utf-8"))
|
||||
_, write, _ = select.select([], [self._sock], [], 0.1)
|
||||
if write:
|
||||
return True
|
||||
except socket.error as e:
|
||||
if e.errno is 32: # broken pipe - no one will read from this pipe anymore
|
||||
return False
|
||||
logging.error(e)
|
||||
return False
|
||||
|
|
|
|||
|
|
@ -55,9 +55,6 @@ class _ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
|
|||
length = int(header.decode("utf-8").strip())
|
||||
data = self.request.recv(length).decode("utf-8")
|
||||
|
||||
if data == "<alive>":
|
||||
continue
|
||||
|
||||
logging.debug("%s recv %d bytes:\n%s", req_name, length, pformat(data))
|
||||
|
||||
# add a new entry and the decoded data dict as an string in utf-8 and an timestamp
|
||||
|
|
|
|||
Loading…
Reference in a new issue