kxg.multiplayer.ClientForum

class kxg.multiplayer.ClientForum(pipe)[source]

Bases: kxg.forums.Forum

Event Handlers:

on_start_game()

on_update_game()

on_finish_game()

Inherited from Forum

on_start_game()

on_update_game()

on_finish_game()

Public Methods:

__init__(pipe)

Initialize self.

receive_id_from_server()

Listen for an id from the server.

connect_everyone(world, actors)

execute_message(message)

execute_sync(message)

Respond when the server indicates that the client is out of sync.

execute_undo(message)

Manage the response when the server rejects a message.

Inherited from Forum

__init__(pipe)

Initialize self.

execute_message(message)

connect_everyone(world, actors)

Private Methods:

_assign_id_factories()

Inherited from Forum

_assign_id_factories()

__init__(pipe)[source]

Initialize self. See help(type(self)) for accurate signature.

_assign_id_factories()[source]
connect_everyone(world, actors)[source]
execute_message(message)[source]
execute_sync(message)[source]

Respond when the server indicates that the client is out of sync.

The server can request a sync when this client sends a message that fails the check() on the server. If the reason for the failure isn’t very serious, then the server can decide to send it as usual in the interest of a smooth gameplay experience. When this happens, the server sends out an extra response providing the clients with the information they need to resync themselves.

execute_undo(message)[source]

Manage the response when the server rejects a message.

An undo is when required this client sends a message that the server refuses to pass on to the other clients playing the game. When this happens, the client must undo the changes that the message made to the world before being sent or crash. Note that unlike sync requests, undo requests are only reported to the client that sent the offending message.

on_finish_game()[source]
on_start_game()[source]
on_update_game()[source]
receive_id_from_server()[source]

Listen for an id from the server. Return true if an id has been received and false otherwise.

At the beginning of a game, each client receives an IdFactory from the server. This factory are used to give id numbers that are guaranteed to be unique to tokens that created locally. This method checks to see if such a factory has been received. If it hasn’t, this method does not block and immediately returns False. If it has, this method returns True after saving the factory internally. At this point it is safe to call Game.start_game(). It is also safe to call this method as many times as you’d like after an id has been received.