server module¶
Server package.
server.handlers¶
Handlers package.
Handlers are classes that manages different objects on the server-side. For instance, they can be responsible for updating the player when a local player packet is sent by the client. The handler will then recuperate that packet and extract its contents to update the server-side player. (Yes, I know this makes the server less authoritative and prone to cheating, but I don’t know about the idea of sending millions of packets to a server whenever a player moves, and then some algorithm that predicts the player’s movement whilst the packets are being processed on the server-side (a.k.a. client predictions)).
server.handlers.player_handler¶
Module name: player_handler
This module handles the server-side player object.
- class game.server.handlers.player_handler.PlayerHandler¶
Bases:
objectClass for creating the player handler.
- get_player(player_name: str) dict[str, int | dict | None]¶
Return player dict by player name if they exist, None otherwise.
- untrack_player(player_name: str) None¶
Untrack the player by removing them from the players list, if possible.
server.handlers.world_handler¶
Module name: world_handler
This module handles the server-side world object.
server.server¶
Module name: server
This module handles the server and updates its state. It also calls the server tasks that send data packets to the client.
(See data/states/server_states for the different server states.) (See server/tasks for the different server tasks.)
server.tasks¶
Module name: tasks
This module defines all the server-side tasks when a connection is being established with a client, or whilst a client is connected. These tasks check the authenticity of the client and any potential errors, as well as send various required packets of game data, requests and responses. These packets are built using the different packet builders.
(See network/builders for the different packet builders.) (See network/protocol for the different requests and responses.)
- class game.server.tasks.ServerTasks¶
Bases:
objectClass for regrouping all server-side requests.
- static game_state(conn, data: bytes, player_handler: PlayerHandler, world_handler: WorldHandler) bool¶
Task for sending the overall game state to a client.
- static incoming_packets(conn, data: bytes, player_handler: PlayerHandler, world_handler: WorldHandler) bool¶
Task for handling incoming packets. Return True if packet is received and is valid, otherwise False
- static local_game_state(conn)¶
Task for requesting a local game state. This is only for specific needs like player data.
- static map_data(conn, addr, world_handler: WorldHandler) None¶
Task for sending map data to a client.
- static player_join(conn, player_handler: PlayerHandler) str¶
Task for joining a client player to the server. Returns the received player name.