MTSC  1.0.5
Build TCP servers out of modules with handlers for communication, exception and logging.
MTSC.Server.Server Class Reference

Basic server class to handle TCP connections. More...

Public Member Functions

 Server ()
 Creates an instance of server with default values. More...
 
 Server (int port)
 Creates an instance of server. More...
 
 Server (X509Certificate2 certificate, int port)
 Creates an instance of server. More...
 
Server SetPort (int port)
 Sets the port to the specified value. More...
 
Server AddHandler (IHandler handler)
 Adds a handler to the server. More...
 
Server AddLogger (ILogger logger)
 Adds a logger to the server. More...
 
Server AddExceptionHandler (IExceptionHandler handler)
 Adds an exception handler to the server. More...
 
void QueueMessage (ClientData target, byte[] message)
 Queues a message to be sent. More...
 
void Log (string log)
 Adds a message to be logged by the associated loggers. More...
 
void LogDebug (string debugMessage)
 Adds a debug message to be logged by the associated loggers. More...
 
void Run ()
 Blocking method. Runs the server on the current thread. More...
 
Task RunAsync ()
 Runs the server async. More...
 
void Stop ()
 Stop the server. More...
 

Properties

int Port [get, set]
 Server port. More...
 
bool Running [get]
 Returns the state of the server. More...
 
List< ClientDataClients [get, set]
 List of clients currently connected to the server. More...
 
bool ScaleUsage [get, set]
 If set to true, the server will use an algorithm to lower or increase the CPU usage based on demands. More...
 
int TickRate [get, set]
 How many times does the server proc per second. Cannot be set higher than 1000. This tickrate will be respected if either the ForceTickrate is set to true or ScaleUsage is set to true and the server is in power saving mode. More...
 
bool ForceTickrate [get, set]
 If set to true, the server will respect the provided TickRate, regardless of current server load. More...
 

Detailed Description

Basic server class to handle TCP connections.

Definition at line 20 of file Server.cs.

Constructor & Destructor Documentation

◆ Server() [1/3]

MTSC.Server.Server.Server ( )

Creates an instance of server with default values.

Definition at line 68 of file Server.cs.

◆ Server() [2/3]

MTSC.Server.Server.Server ( int  port)

Creates an instance of server.

Parameters
portPort to be used by server.

Definition at line 76 of file Server.cs.

◆ Server() [3/3]

MTSC.Server.Server.Server ( X509Certificate2  certificate,
int  port 
)

Creates an instance of server.

Parameters
certificateCertificate for SSL.
portPort to be used by the server.

Definition at line 85 of file Server.cs.

Member Function Documentation

◆ AddExceptionHandler()

Server MTSC.Server.Server.AddExceptionHandler ( IExceptionHandler  handler)

Adds an exception handler to the server.

Parameters
handlerHandler to be added.
Returns
This server object.

Definition at line 127 of file Server.cs.

◆ AddHandler()

Server MTSC.Server.Server.AddHandler ( IHandler  handler)

Adds a handler to the server.

Parameters
handlerHandler to be added.
Returns
This server object.

Definition at line 107 of file Server.cs.

◆ AddLogger()

Server MTSC.Server.Server.AddLogger ( ILogger  logger)

Adds a logger to the server.

Parameters
loggerLogger to be added.
Returns
This server object.

Definition at line 117 of file Server.cs.

◆ Log()

void MTSC.Server.Server.Log ( string  log)

Adds a message to be logged by the associated loggers.

Message to be logged

Definition at line 145 of file Server.cs.

◆ LogDebug()

void MTSC.Server.Server.LogDebug ( string  debugMessage)

Adds a debug message to be logged by the associated loggers.

Debug message to be logged

Definition at line 156 of file Server.cs.

◆ QueueMessage()

void MTSC.Server.Server.QueueMessage ( ClientData  target,
byte []  message 
)

Queues a message to be sent.

Parameters
targetTarget client.
messageMessage to be sent.

Definition at line 137 of file Server.cs.

◆ Run()

void MTSC.Server.Server.Run ( )

Blocking method. Runs the server on the current thread.

Definition at line 166 of file Server.cs.

◆ RunAsync()

Task MTSC.Server.Server.RunAsync ( )

Runs the server async.

Definition at line 381 of file Server.cs.

◆ SetPort()

Server MTSC.Server.Server.SetPort ( int  port)

Sets the port to the specified value.

Parameters
portPort value.
Returns
This server instance.

Definition at line 97 of file Server.cs.

◆ Stop()

void MTSC.Server.Server.Stop ( )

Stop the server.

Definition at line 388 of file Server.cs.

Property Documentation

◆ Clients

List<ClientData> MTSC.Server.Server.Clients
getset

List of clients currently connected to the server.

Definition at line 47 of file Server.cs.

◆ ForceTickrate

bool MTSC.Server.Server.ForceTickrate
getset

If set to true, the server will respect the provided TickRate, regardless of current server load.

Definition at line 62 of file Server.cs.

◆ Port

int MTSC.Server.Server.Port
getset

Server port.

Definition at line 39 of file Server.cs.

◆ Running

bool MTSC.Server.Server.Running
get

Returns the state of the server.

Definition at line 43 of file Server.cs.

◆ ScaleUsage

bool MTSC.Server.Server.ScaleUsage
getset

If set to true, the server will use an algorithm to lower or increase the CPU usage based on demands.

Definition at line 52 of file Server.cs.

◆ TickRate

int MTSC.Server.Server.TickRate
getset

How many times does the server proc per second. Cannot be set higher than 1000. This tickrate will be respected if either the ForceTickrate is set to true or ScaleUsage is set to true and the server is in power saving mode.

Definition at line 58 of file Server.cs.


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