C# Class Fusion.Engine.Server.GameServer

Provides basic client-server interaction and server-side game logic.
Inheritance: Fusion.Engine.Common.GameModule
Mostra file Open project: demiurghg/FusionEngine Class Usage Examples

Private Properties

Property Type Description
DispatchDataIM void
DispatchIM void
DispatchStatusChange void
DispatchUserCommand void
GetPingInternal float
KillInternal void
NotifyClientsInternal void
SendNotifications void
SendSnapshot void
ServerTaskFunc void
StartInternal void
UpdateNetworkAndLogic void
UpdatePings void
Wait void

Public Methods

Method Description
ApproveClient ( System.Guid guid, string userInfo, string &reason ) : bool

Approves client by id and user information.

ClientActivated ( System.Guid clientGuid ) : void

Called when client received snapshot and ready to play.

ClientConnected ( System.Guid clientGuid, string userInfo ) : void

Called when client connected.

ClientDeactivated ( System.Guid clientGuid ) : void

Called when before disconnect.

ClientDisconnected ( System.Guid clientGuid ) : void

Called when client disconnected.

FeedCommand ( System.Guid clientGuid, byte userCommand, uint commandID, float lag ) : void

Feed server with commands from particular client.

FeedNotification ( System.Guid clientGuid, string message ) : void

Feed server with commands from particular client.

GameServer ( Game game ) : System

Initializes a new instance of this class.

GetIP ( System.Guid clientGuid ) : float

Gets ping time to particular client.

GetPing ( System.Guid clientGuid ) : float

Gets ping time to particular client.

LoadContent ( string map ) : void

Method is invoked when server started.

NotifyClients ( string format ) : void

Sends text message to all clients.

ServerInfo ( ) : string

Gets server information that required for client to load the game. This information usually contains map name and game type. This information is also used for discovery response.

UnloadContent ( ) : void

Method is invoked when server shuts down. This method will be also called when server crashes.

Update ( GameTime gameTime ) : byte[]

Runs one step of server-side world simulation. Due to delta compression of snapshot keep data aligned. Even small layout change will cause significiant increase of sending data

Protected Methods

Method Description
Dispose ( bool disposing ) : void

Releases all resources used by the GameServer class.

Private Methods

Method Description
DispatchDataIM ( GameTime gameTime, SnapshotQueue queue, NetIncomingMessage msg ) : void

DispatchIM ( GameTime gameTime, SnapshotQueue queue, Lidgren.Network.NetServer server ) : void

DispatchStatusChange ( NetIncomingMessage msg ) : void

DispatchUserCommand ( GameTime gameTime, SnapshotQueue queue, NetIncomingMessage msg ) : void

GetPingInternal ( System.Guid clientGuid ) : float

KillInternal ( ) : void

Kills server thread.

NotifyClientsInternal ( string message ) : void

SendNotifications ( Lidgren.Network.NetServer server ) : void

SendSnapshot ( Lidgren.Network.NetServer server, SnapshotQueue queue, long serverTicks ) : void

ServerTaskFunc ( string map, string postCommand ) : void

StartInternal ( string map, string postCommand ) : void

Initiate server thread.

UpdateNetworkAndLogic ( GameTime svTime, Lidgren.Network.NetServer server, SnapshotQueue snapshotQueue ) : void

Updates everything related to network and game logic.

UpdatePings ( Lidgren.Network.NetServer server ) : void
Wait ( ) : void

Waits for server thread.

Method Details

ApproveClient() public abstract method

Approves client by id and user information.
public abstract ApproveClient ( System.Guid guid, string userInfo, string &reason ) : bool
guid System.Guid
userInfo string
reason string If method returns false this output parameters contains the reason of denial
return bool

ClientActivated() public abstract method

Called when client received snapshot and ready to play.
public abstract ClientActivated ( System.Guid clientGuid ) : void
clientGuid System.Guid Client GUID.
return void

ClientConnected() public abstract method

Called when client connected.
public abstract ClientConnected ( System.Guid clientGuid, string userInfo ) : void
clientGuid System.Guid Client GUID.
userInfo string User information. Cann't be used as client identifier.
return void

ClientDeactivated() public abstract method

Called when before disconnect.
public abstract ClientDeactivated ( System.Guid clientGuid ) : void
clientGuid System.Guid Client GUID.
return void

ClientDisconnected() public abstract method

Called when client disconnected.
public abstract ClientDisconnected ( System.Guid clientGuid ) : void
clientGuid System.Guid Client IP in format 123.45.67.89:PORT. Could be used as client identifier.
return void

Dispose() protected method

Releases all resources used by the GameServer class.
protected Dispose ( bool disposing ) : void
disposing bool
return void

FeedCommand() public abstract method

Feed server with commands from particular client.
public abstract FeedCommand ( System.Guid clientGuid, byte userCommand, uint commandID, float lag ) : void
clientGuid System.Guid Client's GUID
userCommand byte Client's user command bytes
commandID uint Client's user command index
lag float Lag in seconds
return void

FeedNotification() public abstract method

Feed server with commands from particular client.
public abstract FeedNotification ( System.Guid clientGuid, string message ) : void
clientGuid System.Guid Client's GUID
message string
return void

GameServer() public method

Initializes a new instance of this class.
public GameServer ( Game game ) : System
game Game
return System

GetIP() public method

Gets ping time to particular client.
public GetIP ( System.Guid clientGuid ) : float
clientGuid System.Guid
return float

GetPing() public method

Gets ping time to particular client.
public GetPing ( System.Guid clientGuid ) : float
clientGuid System.Guid
return float

LoadContent() public abstract method

Method is invoked when server started.
public abstract LoadContent ( string map ) : void
map string
return void

NotifyClients() public method

Sends text message to all clients.
public NotifyClients ( string format ) : void
format string
return void

ServerInfo() public abstract method

Gets server information that required for client to load the game. This information usually contains map name and game type. This information is also used for discovery response.
public abstract ServerInfo ( ) : string
return string

UnloadContent() public abstract method

Method is invoked when server shuts down. This method will be also called when server crashes.
public abstract UnloadContent ( ) : void
return void

Update() public abstract method

Runs one step of server-side world simulation. Due to delta compression of snapshot keep data aligned. Even small layout change will cause significiant increase of sending data
public abstract Update ( GameTime gameTime ) : byte[]
gameTime Fusion.Engine.Common.GameTime
return byte[]