TNet 3  3.0.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros
TNet.GameServer Class Reference

Game server logic. Handles new connections, RFCs, and pretty much everything else. Example usage: GameServer gs = new GameServer(); gs.Start(5127); More...

Inheritance diagram for TNet.GameServer:
TNet.FileServer

Public Member Functions

delegate void OnCustomPacket (TcpPlayer player, Buffer buffer, BinaryReader reader, Packet request, bool reliable)
 
delegate void OnPlayerAction (Player p)
 
delegate void OnShutdown ()
 
bool Listen (int port)
 Listen to the specified port. This will overwrite any previous Listen() call as only one port can be listened to at a time. More...
 
bool Start (int tcpPort=0, int udpPort=0)
 Start listening to incoming connections on the specified port. More...
 
void Update ()
 Call this function when you've disabled multi-threading. More...
 
void Stop ()
 Accept socket callback. More...
 
bool LoadFrom (string fileName)
 
bool Load (string fileName)
 Load a previously saved server from the specified file. More...
 
- Public Member Functions inherited from TNet.FileServer
bool SaveFile (string fileName, byte[] data)
 Save the specified file. More...
 
byte[] LoadFile (string fileName)
 Load the specified file. More...
 
bool DeleteFile (string fileName)
 Delete the specified file. More...
 

Public Attributes

const bool isMultiThreaded = true
 
OnCustomPacket onCustomPacket
 Any packet not already handled by the server will go to this function for processing. More...
 
OnPlayerAction onPlayerConnect
 Notification triggered when a player connects and authenticates successfully. More...
 
OnPlayerAction onPlayerDisconnect
 Notification triggered when a player disconnects. More...
 
OnShutdown onShutdown
 Notification triggered when the server shuts down. More...
 
string name = "Game Server"
 Give your server a name. More...
 
LobbyServerLink lobbyLink
 Lobby server link, if one is desired. You can use this to automatically inform a remote lobby server of any changes to this server. More...
 

Static Public Attributes

static ushort gameID = 1
 You will want to make this a unique value. More...
 

Protected Member Functions

virtual bool Verify (BinaryReader reader)
 Extra verification steps, if necessary. More...
 

Properties

bool isActive [get]
 Whether the server is currently actively serving players. More...
 
bool isListening [get, set]
 Whether the server is listening for incoming connections. More...
 
int tcpPort [get]
 Port used for listening to incoming connections. Set when the server is started. More...
 
int udpPort [get]
 Listening port for UDP packets. More...
 
int playerCount [get]
 How many players are currently connected to the server. More...
 
GameClient localClient [get, set]
 Set to a client instance if not using sockets. More...
 

Detailed Description

Game server logic. Handles new connections, RFCs, and pretty much everything else. Example usage: GameServer gs = new GameServer(); gs.Start(5127);

Member Function Documentation

bool TNet.GameServer.Listen ( int  port)

Listen to the specified port. This will overwrite any previous Listen() call as only one port can be listened to at a time.

bool TNet.GameServer.Load ( string  fileName)

Load a previously saved server from the specified file.

bool TNet.GameServer.LoadFrom ( string  fileName)
delegate void TNet.GameServer.OnCustomPacket ( TcpPlayer  player,
Buffer  buffer,
BinaryReader  reader,
Packet  request,
bool  reliable 
)
delegate void TNet.GameServer.OnPlayerAction ( Player  p)
delegate void TNet.GameServer.OnShutdown ( )
bool TNet.GameServer.Start ( int  tcpPort = 0,
int  udpPort = 0 
)

Start listening to incoming connections on the specified port.

void TNet.GameServer.Stop ( )

Accept socket callback.

Stop listening to incoming connections and disconnect all players.

void TNet.GameServer.Update ( )

Call this function when you've disabled multi-threading.

virtual bool TNet.GameServer.Verify ( BinaryReader  reader)
protectedvirtual

Extra verification steps, if necessary.

Member Data Documentation

ushort TNet.GameServer.gameID = 1
static

You will want to make this a unique value.

const bool TNet.GameServer.isMultiThreaded = true
LobbyServerLink TNet.GameServer.lobbyLink

Lobby server link, if one is desired. You can use this to automatically inform a remote lobby server of any changes to this server.

string TNet.GameServer.name = "Game Server"

Give your server a name.

OnCustomPacket TNet.GameServer.onCustomPacket

Any packet not already handled by the server will go to this function for processing.

OnPlayerAction TNet.GameServer.onPlayerConnect

Notification triggered when a player connects and authenticates successfully.

OnPlayerAction TNet.GameServer.onPlayerDisconnect

Notification triggered when a player disconnects.

OnShutdown TNet.GameServer.onShutdown

Notification triggered when the server shuts down.

Property Documentation

bool TNet.GameServer.isActive
get

Whether the server is currently actively serving players.

bool TNet.GameServer.isListening
getset

Whether the server is listening for incoming connections.

GameClient TNet.GameServer.localClient
getset

Set to a client instance if not using sockets.

int TNet.GameServer.playerCount
get

How many players are currently connected to the server.

int TNet.GameServer.tcpPort
get

Port used for listening to incoming connections. Set when the server is started.

int TNet.GameServer.udpPort
get

Listening port for UDP packets.


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