Skip to content

Commit

Permalink
Improve documentation of messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Garanas committed Oct 26, 2024
1 parent 645d001 commit 9424acf
Showing 1 changed file with 62 additions and 24 deletions.
86 changes: 62 additions & 24 deletions server/gameconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,33 @@ async def handle_rehost(self, *args: list[Any]):

async def handle_launch_status(self, status: str):
"""
Currently is sent with status `Rejected` if a matchmaker game failed
to start due to players using differing game settings.
Represents the launch status of a peer.

Check warning on line 512 in server/gameconnection.py

View workflow job for this annotation

GitHub Actions / flake8

trailing whitespace
"""

if status == "Unknown":
pass

if status == "Connecting":
pass

elif status == "Missing local peers":
pass

elif status == "Rejoining":
pass

elif status == "Ready":
pass

elif status == "Ejected":
pass

elif status == "Rejected":
pass

elif status == 'Failed':

Check warning on line 536 in server/gameconnection.py

View workflow job for this annotation

GitHub Actions / flake8

Single quotes found but double quotes preferred
pass

pass

async def handle_bottleneck(self, *args: list[Any]):
Expand Down Expand Up @@ -547,6 +571,19 @@ async def handle_game_full(self):
"""
pass

async def handle_established_peers(self, peerId: str, peerConnectedTo:str):

Check failure on line 574 in server/gameconnection.py

View workflow job for this annotation

GitHub Actions / flake8

missing whitespace after ':'
"""
Send by the lobby when a peer connected to another peer. Message can be send multiple times, by multiple connections.
# Params
- peerId: The identifier of the peer that this connection received the message from
- peerConneectedTo: The list of identifiers that the given peer established a connection to. Is a list stored in a string, separated by spaces. As an example: "1321 22 33 43221 2132"
"""

peerConnectedToList = peerConnectedTo.split(" ")

Check failure on line 583 in server/gameconnection.py

View workflow job for this annotation

GitHub Actions / flake8

local variable 'peerConnectedToList' is assigned to but never used

Check warning on line 583 in server/gameconnection.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

server/gameconnection.py#L583

Unused variable 'peerConnectedToList'

Check notice on line 583 in server/gameconnection.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

server/gameconnection.py#L583

local variable 'peerConnectedToList' is assigned to but never used (F841)

pass

def _mark_dirty(self):
if self.game:
self.game_service.mark_dirty(self.game)
Expand Down Expand Up @@ -623,26 +660,27 @@ def __str__(self):


COMMAND_HANDLERS = {
"AIOption": GameConnection.handle_ai_option,
"Bottleneck": GameConnection.handle_bottleneck,
"BottleneckCleared": GameConnection.handle_bottleneck_cleared,
"Chat": GameConnection.handle_chat,
"ClearSlot": GameConnection.handle_clear_slot,
"Desync": GameConnection.handle_desync,
"Disconnected": GameConnection.handle_disconnected,
"EnforceRating": GameConnection.handle_enforce_rating,
"GameEnded": GameConnection.handle_game_ended,
"GameFull": GameConnection.handle_game_full,
"GameMods": GameConnection.handle_game_mods,
"GameOption": GameConnection.handle_game_option,
"GameResult": GameConnection.handle_game_result,
"GameState": GameConnection.handle_game_state,
"IceMsg": GameConnection.handle_ice_message,
"JsonStats": GameConnection.handle_json_stats,
"LaunchStatus": GameConnection.handle_launch_status,
"OperationComplete": GameConnection.handle_operation_complete,
"PlayerOption": GameConnection.handle_player_option,
"Rehost": GameConnection.handle_rehost,
"TeamkillHappened": GameConnection.handle_teamkill_happened,
"TeamkillReport": GameConnection.handle_teamkill_report,
"AIOption": GameConnection.handle_ai_option, # Lobby message
"Bottleneck": GameConnection.handle_bottleneck, # Lobby/game message
"BottleneckCleared": GameConnection.handle_bottleneck_cleared, # Lobby/game message
"Chat": GameConnection.handle_chat, # Lobby message
"ClearSlot": GameConnection.handle_clear_slot, # Lobby message
"Desync": GameConnection.handle_desync, # Game message
"Disconnected": GameConnection.handle_disconnected, # Lobby message
"EnforceRating": GameConnection.handle_enforce_rating, # Game message
"GameEnded": GameConnection.handle_game_ended, # Game message
"GameFull": GameConnection.handle_game_full, # Lobby message
"GameMods": GameConnection.handle_game_mods, # Lobby message
"GameOption": GameConnection.handle_game_option, # Lobby message
"GameResult": GameConnection.handle_game_result, # Game message
"GameState": GameConnection.handle_game_state, # Lobby/game message
"IceMsg": GameConnection.handle_ice_message, # Lobby/Game message
"JsonStats": GameConnection.handle_json_stats, # Game message
"LaunchStatus": GameConnection.handle_launch_status, # Lobby message
"OperationComplete": GameConnection.handle_operation_complete, # Coop message
"PlayerOption": GameConnection.handle_player_option, # Lobby message
"Rehost": GameConnection.handle_rehost, # Game message
"TeamkillHappened": GameConnection.handle_teamkill_happened, # Game message
"TeamkillReport": GameConnection.handle_teamkill_report, # Game message
"EstablishedPeers": GameConnection.handle_established_peers, # Game message
}

0 comments on commit 9424acf

Please sign in to comment.