mirror of
https://github.com/kuitoi/kuitoi-Server.git
synced 2025-08-17 16:25:36 +00:00
Move sync_resources logic before insert to clients.
This commit is contained in:
parent
dd2c461581
commit
6afe62b68e
@ -77,7 +77,7 @@ class Client:
|
||||
await client.tcp_send(data)
|
||||
return
|
||||
|
||||
self.log.debug(f"tcp_send({data})")
|
||||
# self.log.debug(f"tcp_send({data})")
|
||||
if len(data) == 10:
|
||||
data += b"."
|
||||
header = len(data).to_bytes(4, "little", signed=True)
|
||||
@ -138,10 +138,6 @@ class Client:
|
||||
async def sync_resources(self):
|
||||
while True:
|
||||
data = await self.recv()
|
||||
if not data:
|
||||
await asyncio.sleep(.1)
|
||||
continue
|
||||
self.log.debug(f"Received: {data}")
|
||||
if data.startswith(b"f"):
|
||||
# TODO: SendFile
|
||||
file = data[1:].decode("utf-8")
|
||||
@ -166,8 +162,6 @@ class Client:
|
||||
|
||||
async def looper(self):
|
||||
# self.is_disconnected()
|
||||
await self.tcp_send(b"P" + bytes(f"{self.cid}", "utf-8"))
|
||||
await self.sync_resources()
|
||||
while self.alive:
|
||||
data = await self.recv()
|
||||
if data == b"":
|
||||
|
@ -72,6 +72,8 @@ class TCPServer:
|
||||
return False, None
|
||||
else:
|
||||
self.log.info("Identification success")
|
||||
await client.tcp_send(b"P" + bytes(f"{client.cid}", "utf-8"))
|
||||
await client.sync_resources()
|
||||
await self.Core.insert_client(client)
|
||||
|
||||
return True, client
|
||||
|
Loading…
x
Reference in New Issue
Block a user