cable_club.network.states module

Actual game server, accept user connections and interact with them.

class cable_club.network.states.Connected(peer: socket)[source]

Bases: State

Connected to the server.

handle(socket: socket, server: Server, message: bytes) tuple[State, bool][source]

Forward messages to the peer.

peer: socket
class cable_club.network.states.Connecting[source]

Bases: State

Establishing a connection to the server.

handle(socket: socket, server: Server, message: bytes) tuple[State, bool][source]

Validate the party, and connect to peer if possible.

class cable_club.network.states.Finding(*, peer_id: int, name: str, id_: int, trainertype: str, win_text: str, lose_text: str, party: Party, party_raw: list[str])[source]

Bases: State

Looking for a match.

handle(socket: socket, server: Server, message: bytes) tuple[State, bool][source]

Ignore messages until connected.

write(writer: Writer) None[source]

Dump this state into the received writer.

class cable_club.network.states.State[source]

Bases: ABC

Current state of a client’s connection.

abstract handle(socket: socket, server: Server, message: bytes) tuple[State, bool][source]

Handle a message and return the new state, usually the current one (self).

Second return value represents whether we’ve changed state.

cable_club.network.states.public_id(id_: int) int[source]

Trim an arbitrary int into the expected size.