Skip to content

Commit

Permalink
refactor: rename Client.REQUIRED_VERSION for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
thegamecracks committed Mar 12, 2024
1 parent f9b124c commit 60c2e61
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/dumdum/protocol/client/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
)
)
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 60c2e61

Please sign in to comment.