## Public API Reference

- Main Page
- Classes
- Files

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# iCelGameServer Struct Reference

The main object to manage the server game logic. More...

`#include <physicallayer/network.h>`

List of all members.

## Public Member Functions

virtual void | ChangeLevel (celGameInfo *new_game)=0
| Level change, the game is re-initialized.
virtual void | ChangeLinkControl (iCelEntity *entity, celPlayer *player, bool player_controlled)=0
| Define if it is the client or the server that will update the entity.
virtual iCelPlayerList * | CreateChannel (csStringID channel_id)=0
| Create a channel, ie a list of players.
virtual celPlayer * | GetAdministrator ()=0
| Return the administrator of the game.
virtual void | GetNetworkPlayerStats (celPlayer *player, celNetworkPlayerStats &stats) const =0
| Return the network stats of the specified player.
virtual void | GetNetworkTotalStats (celNetworkPlayerTotalStats &stats) const =0
| Return the network stats of this server.
virtual iCelPlayerList * | GetPlayerList ()=0
| Return the list of players connected to the server.
virtual celPlayerNetworkState | GetPlayerState (celPlayer *player)=0
| Return the state of the network connection to the player.
virtual void | KickPlayer (celPlayer *player, csString reason)=0
| Kick the player from the game, ie the player will be forced to disconnect from the game.
virtual void | LaunchServerEvent (csStringID channel_id, celServerEventData &event_data)=0
| A server event has to be sent to the players in the channel.
virtual void | LaunchServerEvent (celPlayer *player, celServerEventData &event_data)=0
| A server event has to be sent to a player.
virtual void | RegisterServerManager (celGameServerManager *manager)=0
| Register the manager of this server.
virtual void | RemoveChannel (csStringID channel_id)=0
| Stop managing the list of players and delete it.
virtual void | RemoveNetworkLink (iCelEntity *entity, csStringID channel_id)=0
| Remove the existing link between the entity and the channel, ie the state of the entity will no more be sent to the players in the list.
virtual void | RemoveNetworkLink (iCelEntity *entity, celPlayer *player)=0
| Remove the existing link between the entity and the player, ie the state of the entity will no more be sent to the player.
virtual void | SetAdministrator (celPlayer *new_admin)=0
| Set the administrator of the game.
virtual void | SetClientTimeOut (csTicks timeout)=0
| The server will consider a client connected until the connection is broken (network state CEL_NET_PLAYER_UNREACHABLE) during the specified time.
virtual void | SetMaximumBandwidth (size_t width)=0
| Specify the maximum bandwidth of the network data transmission in bytes per second.
virtual void | SetNetworkLink (csStringID channel_id, celNetworkLinkData &link_data)=0
| Establish a link between a source entity and the players in a list.
virtual void | SetNetworkLink (celPlayer *player, celNetworkLinkData &link_data, bool player_controlled)=0
| Establish a link between an entity and a player.
virtual void | SetNetworkPeriod (csTicks period)=0
| Specify the maximum frequency at which the server can send data to clients.

## Detailed Description

The main object to manage the server game logic.

You can use it to:

- get and set the administrator of the game, get the list of players of the game, kick a player from the game.
- create and remove channels, ie list of players.
- send server events, create and remove network links.
- re-initialize a game for example when a new level is started.
- set some options on the server.
- get some network statistics.

You should define and register a celGameServerManager which will catch the events from this server.

Definition at line 341 of file network.h.

## Member Function Documentation

virtual void iCelGameServer::ChangeLevel | ( | celGameInfo * | new_game | ) | `[pure virtual]`

Level change, the game is re-initialized.

Clear all pending network links and server events. The iCelGameClientManager of all players will be called with celGameClientManager::LevelChanged. All the players are marked as CEL_NET_PLAYER_CONNECTING, they will need to do iCelGameClient::SetReady.

Parameters:

  | level_name | a significant name for the new level.

virtual void iCelGameServer::ChangeLinkControl | ( | iCelEntity * | entity,
|  | celPlayer * | player,
|  | bool | player_controlled
| ) | `[pure virtual]`

Define if it is the client or the server that will update the entity.

A network link between the player and the entity must be present.

Parameters:

  | entity | the entity network linked to the player
  | player | the player network linked to the entity
  | player_controlled | false if the entity is controlled by the server, true if it is by the client (ie this is the client that will update the entity and send its state to the server, instead of the contrary).

virtual iCelPlayerList* iCelGameServer::CreateChannel | ( | csStringID | channel_id | ) | `[pure virtual]`

Create a channel, ie a list of players.

The list will be managed by the server which will listen to players disconnecting and will so remove them from the list. Channels are useful to send the same server events or create the same network links to a list of players.

Parameters:

  | channel_id | the ID of the channel

virtual celPlayer* iCelGameServer::GetAdministrator | ( |  | ) | `[pure virtual]`

| Return the administrator of the game. The return value can be 0 if no administrator was defined in iCelGameFactory::CreateGame.

virtual void iCelGameServer::GetNetworkPlayerStats | ( | celPlayer * | player,
|  | celNetworkPlayerStats & | stats
| ) | const`[pure virtual]`

| Return the network stats of the specified player.

virtual void iCelGameServer::GetNetworkTotalStats | ( | celNetworkPlayerTotalStats & | stats | ) | const`[pure virtual]`

| Return the network stats of this server.

virtual iCelPlayerList* iCelGameServer::GetPlayerList | ( |  | ) | `[pure virtual]`

| Return the list of players connected to the server.

virtual celPlayerNetworkState iCelGameServer::GetPlayerState | ( | celPlayer * | player | ) | `[pure virtual]`

| Return the state of the network connection to the player.

virtual void iCelGameServer::KickPlayer | ( | celPlayer * | player,
|  | csString | reason
| ) | `[pure virtual]`

| Kick the player from the game, ie the player will be forced to disconnect from the game. A text explaining the reason can be specified.

virtual void iCelGameServer::LaunchServerEvent | ( | csStringID | channel_id,
|  | celServerEventData & | event_data
| ) | `[pure virtual]`

| A server event has to be sent to the players in the channel.

virtual void iCelGameServer::LaunchServerEvent | ( | celPlayer * | player,
|  | celServerEventData & | event_data
| ) | `[pure virtual]`

| A server event has to be sent to a player.

virtual void iCelGameServer::RegisterServerManager | ( | celGameServerManager * | manager | ) | `[pure virtual]`

| Register the manager of this server. Only one manager can be registered at a time.

virtual void iCelGameServer::RemoveChannel | ( | csStringID | channel_id | ) | `[pure virtual]`

| Stop managing the list of players and delete it. Any existing network links to this channel will also be removed.

virtual void iCelGameServer::RemoveNetworkLink | ( | iCelEntity * | entity,
|  | csStringID | channel_id
| ) | `[pure virtual]`

| Remove the existing link between the entity and the channel, ie the state of the entity will no more be sent to the players in the list.

virtual void iCelGameServer::RemoveNetworkLink | ( | iCelEntity * | entity,
|  | celPlayer * | player
| ) | `[pure virtual]`

| Remove the existing link between the entity and the player, ie the state of the entity will no more be sent to the player.

virtual void iCelGameServer::SetAdministrator | ( | celPlayer * | new_admin | ) | `[pure virtual]`

| Set the administrator of the game. It doesn't need to be a player already connected.

virtual void iCelGameServer::SetClientTimeOut | ( | csTicks | timeout | ) | `[pure virtual]`

| The server will consider a client connected until the connection is broken (network state CEL_NET_PLAYER_UNREACHABLE) during the specified time.

virtual void iCelGameServer::SetMaximumBandwidth | ( | size_t | width | ) | `[pure virtual]`

| Specify the maximum bandwidth of the network data transmission in bytes per second. A bandwidth of 0 means that it is unlimited.

virtual void iCelGameServer::SetNetworkLink | ( | csStringID | channel_id,
|  | celNetworkLinkData & | link_data
| ) | `[pure virtual]`

Establish a link between a source entity and the players in a list.

When a link is set up, a copy entity will be created on each client side and the server manager will send periodically a part of the state of the entity to the copy entity.

If a link between the entity and the channel is already present, the previous link will be removed.

Parameters:

  | channel_id | the ID of the channel
  | link_data | the data of the network link

virtual void iCelGameServer::SetNetworkLink | ( | celPlayer * | player,
|  | celNetworkLinkData & | link_data,
|  | bool | player_controlled
| ) | `[pure virtual]`

Establish a link between an entity and a player.

When a link is set up, a copy entity will be created on the client side and the server manager will send periodically a part of the state of the entity to the copy entity.

If the entity is controlled on the client side, the network link will be in the other direction and the state of the entity will be sent periodically from the client side to the server side.

If a link between the entity and the player is already present, the previous link will be removed.

Parameters:

  | player | the player linked to the entity
  | link_data | the data of the network link
  | player_controlled | false if the entity is controlled by the server, true if it is by the client (ie this is the client that will update the entity and send its state to the server, instead of the contrary).

virtual void iCelGameServer::SetNetworkPeriod | ( | csTicks | period | ) | `[pure virtual]`

Specify the maximum frequency at which the server can send data to clients.

Parameters:

  | period | the number of ticks between two updates from the server. A period of 0 means "as soon as possible".

The documentation for this struct was generated from the following file:

- physicallayer/network.h