SmartEngine  1.6.0
Classes | Public Member Functions | Public Attributes | Properties | List of all members
SmartEngine.Networking.Server Class Reference

Singleton server class to manage listening to a port and accept incoming client connections More...

Inheritance diagram for SmartEngine.Networking.Server:
SmartEngine.SingletonBehavior< Server >

Classes

class  ConnectionAcceptedEvent
 
class  ConnectionDisconnectEvent
 
class  MessageEvent
 
class  ServerStartedEvent
 

Public Member Functions

bool StartServer (string ipPort)
 Starts the server More...
 
bool StartServer (ushort port)
 Starts the server, listening to the specified port More...
 
void StopServer ()
 Stops the server More...
 
void SendMessage (Connection connection, Message message)
 Sends a message to a client. The message is sent asynchronously More...
 
async Task SendMessageAsync (Connection connection, Message message)
 Awaitable version of SendMessage More...
 

Public Attributes

ServerStartedEvent OnServerStarted
 Invoked when the server starts More...
 
ConnectionAcceptedEvent OnConnectionAccepted
 Invoked when a client connects More...
 
ConnectionDisconnectEvent OnConnectionDisconnected
 Invoked when a client disconnects More...
 
MessageEvent OnMessage
 Invoked when a message from the client is received More...
 

Properties

bool IsStarted [get]
 Returns true if the server is started More...
 
List< ConnectionClientConnections [get]
 A list of connected clients More...
 
- Properties inherited from SmartEngine.SingletonBehavior< Server >
static T Instance [get]
 

Detailed Description

Singleton server class to manage listening to a port and accept incoming client connections

Member Function Documentation

◆ SendMessage()

void SmartEngine.Networking.Server.SendMessage ( Connection  connection,
Message  message 
)

Sends a message to a client. The message is sent asynchronously

Parameters
connection
message

◆ SendMessageAsync()

async Task SmartEngine.Networking.Server.SendMessageAsync ( Connection  connection,
Message  message 
)

Awaitable version of SendMessage

Parameters
connection
message
Returns

◆ StartServer() [1/2]

bool SmartEngine.Networking.Server.StartServer ( string  ipPort)

Starts the server

Parameters
ipPortIn the format "[server]:[port]". Only the port is used.
Returns

◆ StartServer() [2/2]

bool SmartEngine.Networking.Server.StartServer ( ushort  port)

Starts the server, listening to the specified port

Parameters
port
Returns

◆ StopServer()

void SmartEngine.Networking.Server.StopServer ( )

Stops the server

Member Data Documentation

◆ OnConnectionAccepted

ConnectionAcceptedEvent SmartEngine.Networking.Server.OnConnectionAccepted

Invoked when a client connects

◆ OnConnectionDisconnected

ConnectionDisconnectEvent SmartEngine.Networking.Server.OnConnectionDisconnected

Invoked when a client disconnects

◆ OnMessage

MessageEvent SmartEngine.Networking.Server.OnMessage

Invoked when a message from the client is received

◆ OnServerStarted

ServerStartedEvent SmartEngine.Networking.Server.OnServerStarted

Invoked when the server starts

Property Documentation

◆ ClientConnections

List<Connection> SmartEngine.Networking.Server.ClientConnections
get

A list of connected clients

◆ IsStarted

bool SmartEngine.Networking.Server.IsStarted
get

Returns true if the server is started