From 093be0058f9b5eaaa2433188525d51a0de3663bb Mon Sep 17 00:00:00 2001 From: alemi Date: Tue, 12 Oct 2021 01:43:29 +0200 Subject: [PATCH] added scaffolding for state logic --- aiocraft/client.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/aiocraft/client.py b/aiocraft/client.py index 6b52392..52456dc 100644 --- a/aiocraft/client.py +++ b/aiocraft/client.py @@ -44,9 +44,27 @@ class Client: async def _logic_worker(self): while self._processing: buffer = await self.dispatcher.incoming.get() + if self.state == ConnectionState.HANDSHAKING: + self.handshaking_logic(buffer) + elif self.state == ConnectionState.LOGIN: + self.login_logic(buffer) + elif self.state == ConnectionState.PLAY: + self.play_logic(buffer) + packet_id = VarInt.deserialize(buffer) cls = PacketRegistry.state(self.state).clientbound.get(packet_id) packet = cls(buffer) # Process packets? switch state, invoke callbacks? Maybe implement Reactors? + async def handshaking_logic(self, buffer: bytes): + pass + + async def status_logic(self, buffer: bytes): + pass + + async def login_logic(self, buffer: bytes): + pass + + async def play_logic(self, buffer: bytes): + pass