mirror of
https://github.com/kuitoi/kuitoi-Server.git
synced 2025-08-17 08:15:42 +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)
|
await client.tcp_send(data)
|
||||||
return
|
return
|
||||||
|
|
||||||
self.log.debug(f"tcp_send({data})")
|
# self.log.debug(f"tcp_send({data})")
|
||||||
if len(data) == 10:
|
if len(data) == 10:
|
||||||
data += b"."
|
data += b"."
|
||||||
header = len(data).to_bytes(4, "little", signed=True)
|
header = len(data).to_bytes(4, "little", signed=True)
|
||||||
@ -138,10 +138,6 @@ class Client:
|
|||||||
async def sync_resources(self):
|
async def sync_resources(self):
|
||||||
while True:
|
while True:
|
||||||
data = await self.recv()
|
data = await self.recv()
|
||||||
if not data:
|
|
||||||
await asyncio.sleep(.1)
|
|
||||||
continue
|
|
||||||
self.log.debug(f"Received: {data}")
|
|
||||||
if data.startswith(b"f"):
|
if data.startswith(b"f"):
|
||||||
# TODO: SendFile
|
# TODO: SendFile
|
||||||
file = data[1:].decode("utf-8")
|
file = data[1:].decode("utf-8")
|
||||||
@ -166,8 +162,6 @@ class Client:
|
|||||||
|
|
||||||
async def looper(self):
|
async def looper(self):
|
||||||
# self.is_disconnected()
|
# self.is_disconnected()
|
||||||
await self.tcp_send(b"P" + bytes(f"{self.cid}", "utf-8"))
|
|
||||||
await self.sync_resources()
|
|
||||||
while self.alive:
|
while self.alive:
|
||||||
data = await self.recv()
|
data = await self.recv()
|
||||||
if data == b"":
|
if data == b"":
|
||||||
|
@ -72,6 +72,8 @@ class TCPServer:
|
|||||||
return False, None
|
return False, None
|
||||||
else:
|
else:
|
||||||
self.log.info("Identification success")
|
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)
|
await self.Core.insert_client(client)
|
||||||
|
|
||||||
return True, client
|
return True, client
|
||||||
|
Loading…
x
Reference in New Issue
Block a user