C4 Engine
C4 Engine API Documentation

Application::HandlePlayerEvent

Defined in:  C4Application.h
Called to handle a player-related event.
Prototype

virtual void HandlePlayerEvent(PlayerEvent event, Player *player, const void *param);

Parameters
event The player event type. See below for a list of possible types.
player The player for which the event occurred.
param A pointer to parameter information for the event.
Description
The HandlePlayerEvent function can be overridden by an application-defined subclass of the Application class. This function is called when an event pertaining to a particular player occurs in a multiplayer game. The event parameter contains one of the following constants.
kPlayerConnected A new player connected to the game.
kPlayerDisconnected A player disconnected from the game.
kPlayerTimedOut A player timed out and was disconnected from the game.
kPlayerInitialized A new player has been initialized and is ready to receive game state.
kPlayerChatReceived A player has sent a chat message.
kPlayerRenamed A player has changed his name.
If the event parameter is kPlayerChatReceived, then the param parameter is a pointer to the chat text string. This string will always have a maximum length of kMaxChatMessageLength characters.

If the event parameter is kPlayerInitialized, then the server has finished initializing a new player in a multiplayer game, and it is about to start sending game state to that player. The event handler should respond to this event by sending one or more application-defined messages back to the player specified by the player parameter in order to make sure it is ready to receive game state. For example, it is usually necessary to send information about what world is currently being played back to the new client at this point. After the kPlayerInitialized is handled, the Message Manager allows all StateSender objects to send their game state, and this is followed by the message journal.
See Also

Application::HandleConnectionEvent

Application::HandleGameEvent