mirror of
https://github.com/kuitoi/kuitoi-Server.git
synced 2025-08-17 16:25:36 +00:00
Minor fixes
This commit is contained in:
parent
de91d075b4
commit
cdec0b9949
@ -44,6 +44,10 @@ class Client:
|
|||||||
def _writer(self):
|
def _writer(self):
|
||||||
return self.__writer
|
return self.__writer
|
||||||
|
|
||||||
|
@property
|
||||||
|
def alive(self):
|
||||||
|
return self.__alive
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def log(self):
|
def log(self):
|
||||||
return self._log
|
return self._log
|
||||||
@ -185,8 +189,8 @@ class Client:
|
|||||||
await writer.drain()
|
await writer.drain()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
except ConnectionError:
|
except Exception as e:
|
||||||
self.log.debug('[TCP] Disconnected')
|
self.log.debug(f'[TCP] Disconnected: {e}')
|
||||||
self.__alive = False
|
self.__alive = False
|
||||||
await self._remove_me()
|
await self._remove_me()
|
||||||
return False
|
return False
|
||||||
@ -280,6 +284,9 @@ class Client:
|
|||||||
async def _sync_resources(self):
|
async def _sync_resources(self):
|
||||||
while self.__alive:
|
while self.__alive:
|
||||||
data = await self._recv(True)
|
data = await self._recv(True)
|
||||||
|
if data is None:
|
||||||
|
await self._remove_me()
|
||||||
|
break
|
||||||
if data.startswith(b"f"):
|
if data.startswith(b"f"):
|
||||||
file = data[1:].decode(config.enc)
|
file = data[1:].decode(config.enc)
|
||||||
self.log.info(i18n.client_mod_request.format(repr(file)))
|
self.log.info(i18n.client_mod_request.format(repr(file)))
|
||||||
@ -358,7 +365,7 @@ class Client:
|
|||||||
id_sep = s.find('-')
|
id_sep = s.find('-')
|
||||||
if id_sep == -1:
|
if id_sep == -1:
|
||||||
self.log.debug(
|
self.log.debug(
|
||||||
f"Invalid packet: Could not parse pid/vid from packet, as there is no '-' separator: '{data}'")
|
f"Invalid packet: Could not parse pid/vid from packet, as there is no '-' separator: '{data}', {s}")
|
||||||
return -1, -1
|
return -1, -1
|
||||||
cid = s[:id_sep]
|
cid = s[:id_sep]
|
||||||
vid = s[id_sep + 1:]
|
vid = s[id_sep + 1:]
|
||||||
@ -549,7 +556,7 @@ class Client:
|
|||||||
|
|
||||||
case "t": # Broken details
|
case "t": # Broken details
|
||||||
self.log.debug(f"Something changed/broken: {raw_data}")
|
self.log.debug(f"Something changed/broken: {raw_data}")
|
||||||
cid, car_id = self._get_cid_vid(raw_data[5:])
|
cid, car_id = self._get_cid_vid(raw_data[2:])
|
||||||
if car_id != -1 and cid == self.cid and self._cars[car_id]:
|
if car_id != -1 and cid == self.cid and self._cars[car_id]:
|
||||||
data = raw_data[raw_data.find("{"):]
|
data = raw_data[raw_data.find("{"):]
|
||||||
ev.call_event("onCarChanged", car_id=car_id, data=data)
|
ev.call_event("onCarChanged", car_id=car_id, data=data)
|
||||||
@ -558,7 +565,7 @@ class Client:
|
|||||||
|
|
||||||
case "m": # Move focus car
|
case "m": # Move focus car
|
||||||
self.log.debug(f"Move focus to: {raw_data}")
|
self.log.debug(f"Move focus to: {raw_data}")
|
||||||
cid, car_id = self._get_cid_vid(raw_data[5:])
|
cid, car_id = self._get_cid_vid(raw_data[3:])
|
||||||
if car_id != -1 and cid == self.cid and self._cars[car_id]:
|
if car_id != -1 and cid == self.cid and self._cars[car_id]:
|
||||||
self._focus_car = car_id
|
self._focus_car = car_id
|
||||||
data = raw_data[raw_data.find("{"):]
|
data = raw_data[raw_data.find("{"):]
|
||||||
|
@ -42,6 +42,8 @@ class Client:
|
|||||||
@property
|
@property
|
||||||
def _writer(self) -> StreamWriter: ...
|
def _writer(self) -> StreamWriter: ...
|
||||||
@property
|
@property
|
||||||
|
def alive(self) -> bool: ...
|
||||||
|
@property
|
||||||
def log(self) -> Logger: ...
|
def log(self) -> Logger: ...
|
||||||
@property
|
@property
|
||||||
def addr(self) -> Tuple[str, int]: ...
|
def addr(self) -> Tuple[str, int]: ...
|
||||||
|
Loading…
x
Reference in New Issue
Block a user