Skip to content

Commit

Permalink
Add _synced #1
Browse files Browse the repository at this point in the history
  • Loading branch information
SantaSpeen committed Aug 17, 2023
1 parent 42e4a8e commit a06c48d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/core/Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(self, reader, writer, core):
self.nick = None
self.roles = None
self._guest = True
self._synced = False
self._ready = False
self._identifiers = []
self._cars = [None] * 21 # Max 20 cars per player + 1 snowman
Expand Down Expand Up @@ -72,6 +73,10 @@ def key(self):
def guest(self):
return self._guest

@property
def synced(self):
return self._synced

@property
def ready(self):
return self._ready
Expand Down Expand Up @@ -706,6 +711,7 @@ async def _looper(self):
tasks = self.__tasks
recv = asyncio.create_task(self._recv())
tasks.append(recv)
self._synced = True
while self.__alive:
if len(self.__packets_queue) > 0:
for index, packet in enumerate(self.__packets_queue):
Expand Down
3 changes: 3 additions & 0 deletions src/core/Client.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Client:
self.roles: str = None
self._guest = True
self.__alive = True
self._synced = False
self._ready = False
self._focus_car = -1
self._identifiers = []
Expand All @@ -55,6 +56,8 @@ class Client:
@property
def guest(self) -> bool: ...
@property
def synced(self) -> bool: ...
@property
def ready(self) -> bool: ...
@property
def identifiers(self) -> list: ...
Expand Down
2 changes: 1 addition & 1 deletion src/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def get_client(self, cid=None, nick=None):
return None
if cid is not None:
if cid == -1:
return [i for i in self.clients if i is not None]
return [i for i in self.clients if i is not None and i.synced]
return self.clients_by_id.get(cid)
if nick:
return self.clients_by_nick.get(nick)
Expand Down

0 comments on commit a06c48d

Please sign in to comment.