Windward
Action-adventure RPG available on Steam Early Access
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros
Public Member Functions | Public Attributes | Properties | List of all members
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 Start (int tcpPort)
 Start listening to incoming connections on the specified port. More...
 
bool Start (int tcpPort, int udpPort)
 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...
 
void MakePrivate ()
 Stop listening to incoming connections but keep the server running. More...
 
void SaveTo (string fileName)
 Save the server's current state into the specified file so it can be easily restored later. More...
 
bool LoadFrom (string fileName)
 Load a previously saved server from the specified file. More...
 
- Public Member Functions inherited from TNet.FileServer
void SaveFile (string fileName, byte[] data)
 Save the specified file. More...
 
byte[] LoadFile (string fileName)
 Load the specified file. More...
 
void DeleteFile (string fileName)
 Delete the specified file. More...
 

Public Attributes

const bool isMultiThreaded = true
 
const ushort gameID = 1
 You will want to make this a unique value. More...
 
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...
 

Properties

bool isActive [get]
 Whether the server is currently actively serving players. More...
 
bool isListening [get]
 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...
 

Additional Inherited Members

- Protected Member Functions inherited from TNet.FileServer
void Error (string error)
 Log an error message. 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.LoadFrom ( string  fileName)

Load a previously saved server from the specified file.

void TNet.GameServer.MakePrivate ( )

Stop listening to incoming connections but keep the server running.

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 ( )
void TNet.GameServer.SaveTo ( string  fileName)

Save the server's current state into the specified file so it can be easily restored later.

bool TNet.GameServer.Start ( int  tcpPort)

Start listening to incoming connections on the specified port.

bool TNet.GameServer.Start ( int  tcpPort,
int  udpPort 
)

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.

Member Data Documentation

const ushort TNet.GameServer.gameID = 1

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
get

Whether the server is listening for incoming connections.

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: