C4 Engine
C4 Engine API Documentation

class StateSender

Defined in:  C4Messages.h
Encapsulates a callback function that sends initial game state in a multiplayer game.
Definition

class StateSender : public ListElement<StateSender>

Constructor

StateSender(SenderCallback *callback, void *cookie);

Parameters
callback A pointer to the state-sending callback function.
cookie A pointer to application-defined data that is passed to the state-sending callback function.
Description
The StateSender class encapsulates a callback function that is called whenever a new client machine joins a multiplayer game. All state-sending callback functions are called immediately after the Message Manager sends the kPlayerInitialized event to the Application::HandlePlayerEvent function on the server machine. The function pointed to by the callback parameter should have the following prototype.

typedef void SenderCallback(Player *to, void *);

The state-sending callback function should send any necessary messages to the player specified by the to parameter in order to synchronize some kind of initial game state.

The World Manager installs a state-sending callback function that sends initial controller state messages to a new client. A controller can send initial game state messages by overriding the Controller::SendInitialStateMessages function.
Base Classes
ListElement<StateSender> Used internally by the Message Manager.
See Also

MessageMgr::InstallStateSender

Controller::SendInitialStateMessages