socha.api.protocol.protocol#

Module Contents#

Classes#

OriginalRequest

Errorpacket

OriginalRequest

Errorpacket

Left

If the game is over the server will _send this message to the clients and closes the connection afterward.

MoveRequest

Request a client to _send a Move.

Close

Is sent by one party immediately before this party closes the communication connection and should make the

Authenticate

Authenticates a client as administrator to _send AdminLobbyRequest`s.

Cancel

Deletes the GameRoom and cancels the Game within.

JoinedGameRoom

Sent to all administrative clients after a player joined a GameRoom via a JoinRoomRequest.

Observe

Sent to client as response to successfully joining a GameRoom as Observer.

Pause

Indicates to observers that the game has been (un)paused.

Slot

Slots for a game which contains the player's name and its attributes.

Step

When the client is authenticated as administrator,

Prepare

When the client is authenticated as administrator,

Join

Joins any room that is open.

JoinPrepared

Join a prepared room with a reservation code.

JoinRoom

To join a room with a room_id.

Fragment

This holds the fragments of a winning definition.

Joined

Sent to all clients after a player joined a GameRoom via a Join Request.

Player

The player that has won the game.

Score

Score of the players when the game has ended.

Winner

The winner of a game.

Definition

The definition of a result of a game.

Entry

Is _send when a game is won by one of the players.

Scores

Then result of a game when its over.

WelcomeMessage

Welcome message is sent to the client when the client joins the room.

Result

Result of a game.

Acceleration

Advance

Center

Fragment

This holds the fragments of a winning definition.

Player

The player that has won the game.

Position

Push

Score

Score of the players when the game has ended.

Turn

Winner

The winner of a game.

Actions

OriginalMessage

The original message that was sent by the client.

Error

This sends the server when the client sent a erroneous message.

Definition

The definition of a result of a game.

Entry

Is _send when a game is won by one of the players.

Passenger

Water

Goal

Sandbank

Island

FieldArray

Ship

LastMove

Scores

Then result of a game when its over.

Segment

Board

State

Data

Room

Prepared

Observed

Prepared

Observed

Protocol

This is the root element of the protocol.

class socha.api.protocol.protocol.OriginalRequest#

Bases: socha.api.protocol.protocol_packet.ProtocolPacket

class Meta#
name = 'originalRequest'#
class_value: str | None#
reservation_code: str | None#
class socha.api.protocol.protocol.Errorpacket#

Bases: socha.api.protocol.protocol_packet.ProtocolPacket

class Meta#
name = 'errorpacket'#
message: str | None#
original_request: OriginalRequest | None#
class socha.api.protocol.protocol.OriginalRequest#

Bases: socha.api.protocol.protocol_packet.ProtocolPacket

class Meta#
name = 'originalRequest'#
class_value: str | None#
reservation_code: str | None#
class socha.api.protocol.protocol.Errorpacket#

Bases: socha.api.protocol.protocol_packet.ProtocolPacket

class Meta#
name = 'errorpacket'#
message: str | None#
original_request: OriginalRequest | None#
class socha.api.protocol.protocol.Left#

Bases: socha.api.protocol.protocol_packet.ProtocolPacket

If the game is over the server will _send this message to the clients and closes the connection afterward.

class Meta#
name = 'left'#
room_id: str | None#
class socha.api.protocol.protocol.MoveRequest#

Bases: socha.api.protocol.room_message.RoomMessage

Request a client to _send a Move.

class socha.api.protocol.protocol.Close#

Bases: socha.api.protocol.protocol_packet.ProtocolPacket

Is sent by one party immediately before this party closes the communication connection and should make the receiving party also close the connection.

This should not be sent manually, the XFluxClient will automatically _send it when stopped.

class Meta#
name = 'close'#
class socha.api.protocol.protocol.Authenticate#

Bases: socha.api.protocol.protocol_packet.AdminLobbyRequest

Authenticates a client as administrator to _send AdminLobbyRequest`s.

Is not answered if successful.

class Meta#
name = 'authenticate'#
password: str | None#
class socha.api.protocol.protocol.Cancel#

Bases: socha.api.protocol.protocol_packet.AdminLobbyRequest

Deletes the GameRoom and cancels the Game within.

class Meta#
name = 'cancel'#
room_id: str | None#
class socha.api.protocol.protocol.JoinedGameRoom#

Bases: socha.api.protocol.room_message.ObservableRoomMessage

Sent to all administrative clients after a player joined a GameRoom via a JoinRoomRequest.

class Meta#
name = 'joinedGameRoom'#
room_id: str | None#
player_count: int | None#
class socha.api.protocol.protocol.Observe#

Bases: socha.api.protocol.protocol_packet.AdminLobbyRequest

Sent to client as response to successfully joining a GameRoom as Observer.

class Meta#
name = 'observe'#
room_id: str | None#
class socha.api.protocol.protocol.Pause#

Bases: socha.api.protocol.protocol_packet.AdminLobbyRequest

Indicates to observers that the game has been (un)paused.

class Meta#
name = 'pause'#
room_id: str | None#
pause: bool | None#
class socha.api.protocol.protocol.Slot#

Bases: socha.api.protocol.room_message.RoomOrchestrationMessage

Slots for a game which contains the player’s name and its attributes.

class Meta#
name = 'slot'#
display_name: str | None#
can_timeout: bool | None#
reserved: bool | None#
class socha.api.protocol.protocol.Step#

Bases: socha.api.protocol.room_message.RoomOrchestrationMessage

When the client is authenticated as administrator, it can _send this step request to the server to advance the game for one move. This is not possible if the game is not paused.

class Meta#
name = 'step'#
room_id: str | None#
class socha.api.protocol.protocol.Prepare#

Bases: socha.api.protocol.room_message.RoomOrchestrationMessage

When the client is authenticated as administrator, it can _send this request to prepare the room for the game.

class Meta#
name = 'prepare'#
game_type: str | None#
pause: bool | None#
slot: List[Slot]#
class socha.api.protocol.protocol.Join#

Bases: socha.api.protocol.protocol_packet.LobbyRequest

Joins any room that is open. If no room is open, a new room is created by the server.

class Meta#
name = 'join'#
class socha.api.protocol.protocol.JoinPrepared#

Bases: socha.api.protocol.protocol_packet.LobbyRequest

Join a prepared room with a reservation code.

class Meta#
name = 'joinPrepared'#
reservation_code: str | None#
class socha.api.protocol.protocol.JoinRoom#

Bases: socha.api.protocol.protocol_packet.LobbyRequest

To join a room with a room_id.

class Meta#
name = 'joinRoom'#
room_id: str | None#
class socha.api.protocol.protocol.Fragment#

This holds the fragments of a winning definition.

class Meta#
name = 'fragment'#
name: str | None#
aggregation: str | None#
relevant_for_ranking: bool | None#
class socha.api.protocol.protocol.Joined#

Bases: socha.api.protocol.protocol_packet.ResponsePacket

Sent to all clients after a player joined a GameRoom via a Join Request.

class Meta#
name = 'joined'#
room_id: str | None#
class socha.api.protocol.protocol.Player#

The player that has won the game.

class Meta#
name = 'player'#
name: str | None#
team: str | None#
class socha.api.protocol.protocol.Score#

Score of the players when the game has ended.

class Meta#
name = 'score'#
cause: str | None#
reason: object | None#
part: List[int]#
class socha.api.protocol.protocol.Winner#

The winner of a game.

class Meta#
name = 'winner'#
team: str | None#
class socha.api.protocol.protocol.Definition#

The definition of a result of a game. If for instance one player made an error move, the game is over and the other player wins, the definition will tell that the other player wins, because of the error.

class Meta#
name = 'definition'#
fragment: List[Fragment]#
class socha.api.protocol.protocol.Entry#

Is _send when a game is won by one of the players. This element contains the winning player and the score of the player.

class Meta#
name = 'entry'#
player: Player | None#
score: Score | None#
class socha.api.protocol.protocol.Scores#

Then result of a game when its over.

class Meta#
name = 'scores'#
entry: List[Entry]#
class socha.api.protocol.protocol.WelcomeMessage#

Bases: socha.api.protocol.room_message.RoomOrchestrationMessage

Welcome message is sent to the client when the client joins the room. In this message the server tells the client which team it is.

team: socha._socha.TeamEnum#
class socha.api.protocol.protocol.Result#

Bases: socha.api.protocol.room_message.ObservableRoomMessage

Result of a game. This will the server _send after a game is finished.

definition: Definition#
scores: Scores#
winner: Winner#
class socha.api.protocol.protocol.Acceleration#
class Meta#
name = 'acceleration'#
acc: int | None#
class socha.api.protocol.protocol.Advance#
class Meta#
name = 'advance'#
distance: int | None#
class socha.api.protocol.protocol.Center#
class Meta#
name = 'center'#
q: int | None#
r: int | None#
s: int | None#
class socha.api.protocol.protocol.Fragment#
class Meta#
name = 'fragment'#
name: str | None#
aggregation: str | None#
relevant_for_ranking: bool | None#
class socha.api.protocol.protocol.Player#
class Meta#
name = 'player'#
name: str | None#
team: str | None#
class socha.api.protocol.protocol.Position#
class Meta#
name = 'position'#
q: int | None#
r: int | None#
s: int | None#
class socha.api.protocol.protocol.Push#
class Meta#
name = 'push'#
direction: str | None#
class socha.api.protocol.protocol.Score#
class Meta#
name = 'score'#
cause: str | None#
reason: object | None#
part: List[int]#
class socha.api.protocol.protocol.Turn#
class Meta#
name = 'turn'#
direction: str | None#
class socha.api.protocol.protocol.Winner#
class Meta#
name = 'winner'#
team: str | None#
class socha.api.protocol.protocol.Actions#
class Meta#
name = 'actions'#
actions: List[object]#
class socha.api.protocol.protocol.OriginalMessage#

The original message that was sent by the client. Is sent by the server if an error occurs.

class Meta#
name = 'originalMessage'#
class_value: str | None#
actions: Actions | None#
class socha.api.protocol.protocol.Error#

This sends the server when the client sent a erroneous message.

message: str#
originalMessage: OriginalMessage#
class socha.api.protocol.protocol.Definition#
class Meta#
name = 'definition'#
fragment: List[Fragment]#
class socha.api.protocol.protocol.Entry#
class Meta#
name = 'entry'#
player: Player | None#
score: Score | None#
class socha.api.protocol.protocol.Passenger#
class Meta#
name = 'passenger'#
direction: str | None#
passenger: int | None#
class socha.api.protocol.protocol.Water#
class Meta#
name = 'water'#
class socha.api.protocol.protocol.Goal#
class Meta#
name = 'goal'#
class socha.api.protocol.protocol.Sandbank#
class Meta#
name = 'sandbank'#
class socha.api.protocol.protocol.Island#
class Meta#
name = 'island'#
class socha.api.protocol.protocol.FieldArray#
class Meta#
name = 'field-array'#
field: List[object]#
class socha.api.protocol.protocol.Ship#
class Meta#
name = 'ship'#
team: str | None#
direction: str | None#
speed: int | None#
coal: int | None#
passengers: int | None#
free_turns: int | None#
points: int | None#
position: Position | None#
class socha.api.protocol.protocol.LastMove#
class Meta#
name = 'lastMove'#
actions: Actions | None#
class socha.api.protocol.protocol.Scores#
class Meta#
name = 'scores'#
entry: List[Entry]#
class socha.api.protocol.protocol.Segment#
class Meta#
name = 'segment'#
direction: str | None#
center: Center | None#
field_array: List[FieldArray]#
class socha.api.protocol.protocol.Board#
class Meta#
name = 'board'#
next_direction: str | None#
segment: List[Segment]#
class socha.api.protocol.protocol.State#

Bases: socha.api.protocol.room_message.ObservableRoomMessage

class Meta#
name = 'state'#
class_value: str | None#
start_team: str | None#
turn: int | None#
current_team: str | None#
board: Board | None#
ship: List[Ship]#
last_move: LastMove | None#
class socha.api.protocol.protocol.Data#
class Meta#
name = 'data'#
class_value: str | None#
class_binding: object | None#
definition: Definition | None#
scores: Scores | None#
winner: Winner | None#
state: State | None#
actions: Actions | None#
original_message: OriginalMessage | None#
color: str | None#
message: str | None#
class socha.api.protocol.protocol.Room#

Bases: socha.api.protocol.protocol_packet.ProtocolPacket

class Meta#
name = 'room'#
room_id: str | None#
data: Data | None#
class socha.api.protocol.protocol.Prepared#

Bases: socha.api.protocol.room_message.RoomOrchestrationMessage

class Meta#
name = 'prepared'#
room_id: str | None#
reservation: List[str]#
class socha.api.protocol.protocol.Observed#

Bases: socha.api.protocol.room_message.RoomOrchestrationMessage

class Meta#
name = 'observed'#
room_id: str | None#
class socha.api.protocol.protocol.Prepared#

Bases: socha.api.protocol.room_message.RoomOrchestrationMessage

class Meta#
name = 'prepared'#
room_id: str | None#
reservation: List[str]#
class socha.api.protocol.protocol.Observed#

Bases: socha.api.protocol.room_message.RoomOrchestrationMessage

class Meta#
name = 'observed'#
room_id: str | None#
class socha.api.protocol.protocol.Protocol#

This is the root element of the protocol. Even it’s in here it will never be called, because the children of this root element have to be handled separately.

class Meta#
name = 'protocol'#
authenticate: Authenticate | None#
joined_game_room: JoinedGameRoom | None#
prepare: Prepare | None#
observe: Observe | None#
pause: Pause | None#
step: Step | None#
cancel: Cancel | None#
join: Join | None#
joined: Joined | None#
room: List[Room]#
prepared: Prepared | None#
observed: Observed | None#