From 60c2e6133f8c8c5a668e4d7d85375f4c8651f8e5 Mon Sep 17 00:00:00 2001 From: thegamecracks <61257169+thegamecracks@users.noreply.github.com> Date: Tue, 12 Mar 2024 12:49:04 -0400 Subject: [PATCH] refactor: rename Client.REQUIRED_VERSION for consistency --- src/dumdum/protocol/client/protocol.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dumdum/protocol/client/protocol.py b/src/dumdum/protocol/client/protocol.py index 727b26a..90ae1b2 100644 --- a/src/dumdum/protocol/client/protocol.py +++ b/src/dumdum/protocol/client/protocol.py @@ -31,7 +31,7 @@ class ClientState(Enum): class Client(Protocol): """The client connected to a server.""" - REQUIRED_VERSION = 0 + PROTOCOL_VERSION = 0 def __init__(self, nick: str) -> None: self.nick = nick @@ -47,7 +47,7 @@ def authenticate(self) -> bytes: self._assert_state(ClientState.AWAITING_AUTHENTICATION) return bytes( ClientMessageAuthenticate( - version=self.REQUIRED_VERSION, + version=self.PROTOCOL_VERSION, nick=self.nick, ) ) @@ -84,7 +84,7 @@ def _maybe_parse_buffer(self) -> ParsedData: def _read_message(self, reader: Reader) -> ParsedData: t = ServerMessageType(reader.readexactly(1)[0]) if t == ServerMessageType.INCOMPATIBLE_VERSION: - return self._parse_required_version(reader) + return self._parse_incompatible_version(reader) elif t == ServerMessageType.ACKNOWLEDGE_AUTHENTICATION: return self._accept_authentication(reader) elif t == ServerMessageType.SEND_MESSAGE: @@ -94,10 +94,10 @@ def _read_message(self, reader: Reader) -> ParsedData: raise RuntimeError(f"No handler for {t}") - def _parse_required_version(self, reader: Reader) -> ParsedData: + def _parse_incompatible_version(self, reader: Reader) -> ParsedData: self._assert_state(ClientState.AWAITING_AUTHENTICATION) version = reader.readexactly(1)[0] - event = ClientEventIncompatibleVersion(version, self.REQUIRED_VERSION) + event = ClientEventIncompatibleVersion(version, self.PROTOCOL_VERSION) return [event], b"" def _accept_authentication(self, reader: Reader) -> ParsedData: