SimpleWebSocketServer Library  v1.0.1
A simple to use websocket with a very easy way to get it to work, just requires four lines of code.
SimpleWebSocketServerLibrary.SimpleWebSocketServer Class Reference

Middleware class for interfacing with the WebSocketHandler and WebSocketHttpServer class. More...

+ Collaboration diagram for SimpleWebSocketServerLibrary.SimpleWebSocketServer:

Public Member Functions

 SimpleWebSocketServer (SimpleWebSocketServerSettings settings)
 Constructor for setting up the Library. More...
 
 SimpleWebSocketServer ()
 Overload constructor for setting up library with default values. More...
 
async Task StartServerAsync ()
 Starts running the server async. More...
 
void StartServer ()
 Starts running the server async. More...
 
async Task< bool > SendTextMessageAsync (string messageToSend, string clientId=null)
 Overload method for sending text messages to a specific client, using it's id, asynchronous. More...
 
bool SendTextMessage (string messageToSend, string clientId=null)
 Overload method for sending text messages to a specific client, using it's id, synchronous. More...
 
async Task< bool > SendBinaryMessageAsync (byte[] messageToSend, string clientId=null)
 Sends a binary "message" to a specific client asynchronous. More...
 
bool SendBinaryMessage (byte[] messageToSend, string clientId=null)
 Sends a binary "message" to a specific client synchronous. More...
 
async Task< bool > SendPingMessageAsync (string messageToSend="", string clientId=null)
 Sends a ping message to all clients asynchronous, can have message. More...
 
bool SendPingMessage (string messageToSend="", string clientId=null)
 Sends a ping message to all clients synchronous, can have message. More...
 
async Task< bool > SendPongMessageAsync (string messageToSend="", string clientId=null)
 Send pong message to all available clients asynchronous, can have message. More...
 
bool SendPongMessage (string messageToSend="", string clientId=null)
 Send pong message to all available clients synchronous, can have message. More...
 
async Task< bool > StopClientAsync (string clientId, string reason="")
 Stops a connection with a specific client asynchronous. Can provide reason. More...
 
bool StopClient (string clientId, string reason="")
 Stops a connection with a specific client synchronous. Can provide reason. More...
 
async Task< bool > StopAllAsync (string reason="")
 Stops all connections with all clients asynchronous. Can provide reason. More...
 
bool StopAll (string reason="")
 Stops all connections with all clients synchronous. Can provide reason. More...
 

Events

EventHandler< WebSocketEventArgWebsocketServerEvent
 Eventhandler for when events such as receiving messages and errors from the websocket server happen. More...
 

Private Member Functions

void OnWebsocketServerEvent (object sender, WebSocketEventArg arg)
 Event handler for receiving websocket messages from the websocket handler. More...
 

Private Attributes

readonly IWebSocketHandler _WebsocketHandler
 Interface for the WebSocketHandler class. More...
 
readonly IWebSocketHttpServer _WebSocketHttpServer
 Interface for the WebSocketHttpServer class. More...
 

Detailed Description

Middleware class for interfacing with the WebSocketHandler and WebSocketHttpServer class.

Definition at line 12 of file SimpleWebsocketServer.cs.

Constructor & Destructor Documentation

◆ SimpleWebSocketServer() [1/2]

SimpleWebSocketServerLibrary.SimpleWebSocketServer.SimpleWebSocketServer ( SimpleWebSocketServerSettings  settings)

Constructor for setting up the Library.

Parameters
settingsSettings with default values.

Definition at line 33 of file SimpleWebsocketServer.cs.

+ Here is the call graph for this function:

◆ SimpleWebSocketServer() [2/2]

SimpleWebSocketServerLibrary.SimpleWebSocketServer.SimpleWebSocketServer ( )

Overload constructor for setting up library with default values.

Definition at line 43 of file SimpleWebsocketServer.cs.

Member Function Documentation

◆ OnWebsocketServerEvent()

void SimpleWebSocketServerLibrary.SimpleWebSocketServer.OnWebsocketServerEvent ( object  sender,
WebSocketEventArg  arg 
)
private

Event handler for receiving websocket messages from the websocket handler.

Parameters
senderInstance of firing class.
argArguments for event.

Definition at line 50 of file SimpleWebsocketServer.cs.

+ Here is the caller graph for this function:

◆ SendBinaryMessage()

bool SimpleWebSocketServerLibrary.SimpleWebSocketServer.SendBinaryMessage ( byte []  messageToSend,
string  clientId = null 
)

Sends a binary "message" to a specific client synchronous.

Parameters
messageToSendMessage in binary format (byte array).
clientIdClient to send to.
Returns
True when succesfully send.

Definition at line 144 of file SimpleWebsocketServer.cs.

+ Here is the call graph for this function:

◆ SendBinaryMessageAsync()

async Task<bool> SimpleWebSocketServerLibrary.SimpleWebSocketServer.SendBinaryMessageAsync ( byte []  messageToSend,
string  clientId = null 
)

Sends a binary "message" to a specific client asynchronous.

Parameters
messageToSendMessage in binary format (byte array).
clientIdClient to send to.
Returns
True when succesfully send.

Definition at line 122 of file SimpleWebsocketServer.cs.

+ Here is the call graph for this function:

◆ SendPingMessage()

bool SimpleWebSocketServerLibrary.SimpleWebSocketServer.SendPingMessage ( string  messageToSend = "",
string  clientId = null 
)

Sends a ping message to all clients synchronous, can have message.

Parameters
messageToSendPossible extra message to send along ping.
clientIdSet clientId in case you want to send to a specific client.
Returns
True when succesfully send.

Definition at line 187 of file SimpleWebsocketServer.cs.

+ Here is the call graph for this function:

◆ SendPingMessageAsync()

async Task<bool> SimpleWebSocketServerLibrary.SimpleWebSocketServer.SendPingMessageAsync ( string  messageToSend = "",
string  clientId = null 
)

Sends a ping message to all clients asynchronous, can have message.

Parameters
messageToSendPossible extra message to send along ping.
clientIdSet clientId in case you want to send to a specific client.
Returns
True when succesfully send.

Definition at line 166 of file SimpleWebsocketServer.cs.

+ Here is the call graph for this function:

◆ SendPongMessage()

bool SimpleWebSocketServerLibrary.SimpleWebSocketServer.SendPongMessage ( string  messageToSend = "",
string  clientId = null 
)

Send pong message to all available clients synchronous, can have message.

Parameters
messageToSendPossible extra message to send along ping.
clientIdSet clientId in case you want to send to a specific client.
Returns
True when succesfully send.

Definition at line 229 of file SimpleWebsocketServer.cs.

+ Here is the call graph for this function:

◆ SendPongMessageAsync()

async Task<bool> SimpleWebSocketServerLibrary.SimpleWebSocketServer.SendPongMessageAsync ( string  messageToSend = "",
string  clientId = null 
)

Send pong message to all available clients asynchronous, can have message.

Parameters
messageToSendPossible extra message to send along ping.
clientIdSet clientId in case you want to send to a specific client.
Returns
True when succesfully send.

Definition at line 208 of file SimpleWebsocketServer.cs.

+ Here is the call graph for this function:

◆ SendTextMessage()

bool SimpleWebSocketServerLibrary.SimpleWebSocketServer.SendTextMessage ( string  messageToSend,
string  clientId = null 
)

Overload method for sending text messages to a specific client, using it's id, synchronous.

Parameters
messageToSend
clientId
Returns
True when send succesfully.

Definition at line 99 of file SimpleWebsocketServer.cs.

+ Here is the call graph for this function:

◆ SendTextMessageAsync()

async Task<bool> SimpleWebSocketServerLibrary.SimpleWebSocketServer.SendTextMessageAsync ( string  messageToSend,
string  clientId = null 
)

Overload method for sending text messages to a specific client, using it's id, asynchronous.

Parameters
messageToSend
clientId
Returns
True when send succesfully.

Definition at line 77 of file SimpleWebsocketServer.cs.

+ Here is the call graph for this function:

◆ StartServer()

void SimpleWebSocketServerLibrary.SimpleWebSocketServer.StartServer ( )

Starts running the server async.

Definition at line 66 of file SimpleWebsocketServer.cs.

+ Here is the call graph for this function:

◆ StartServerAsync()

async Task SimpleWebSocketServerLibrary.SimpleWebSocketServer.StartServerAsync ( )

Starts running the server async.

Definition at line 58 of file SimpleWebsocketServer.cs.

+ Here is the call graph for this function:

◆ StopAll()

bool SimpleWebSocketServerLibrary.SimpleWebSocketServer.StopAll ( string  reason = "")

Stops all connections with all clients synchronous. Can provide reason.

Parameters
reasonPossible reason to close the connection.
Returns
True when succesfully closed.

Definition at line 303 of file SimpleWebsocketServer.cs.

+ Here is the call graph for this function:

◆ StopAllAsync()

async Task<bool> SimpleWebSocketServerLibrary.SimpleWebSocketServer.StopAllAsync ( string  reason = "")

Stops all connections with all clients asynchronous. Can provide reason.

Parameters
reasonPossible reason to close the connection.
Returns
True when succesfully closed.

Definition at line 286 of file SimpleWebsocketServer.cs.

+ Here is the call graph for this function:

◆ StopClient()

bool SimpleWebSocketServerLibrary.SimpleWebSocketServer.StopClient ( string  clientId,
string  reason = "" 
)

Stops a connection with a specific client synchronous. Can provide reason.

Parameters
clientIdSpecific client to close connection with.
reasonPossible reason to close the connection.
Returns
True when succesfully closed.

Definition at line 268 of file SimpleWebsocketServer.cs.

+ Here is the call graph for this function:

◆ StopClientAsync()

async Task<bool> SimpleWebSocketServerLibrary.SimpleWebSocketServer.StopClientAsync ( string  clientId,
string  reason = "" 
)

Stops a connection with a specific client asynchronous. Can provide reason.

Parameters
clientIdSpecific client to close connection with.
reasonPossible reason to close the connection.
Returns
True when succesfully closed.

Definition at line 250 of file SimpleWebsocketServer.cs.

+ Here is the call graph for this function:

Member Data Documentation

◆ _WebsocketHandler

readonly IWebSocketHandler SimpleWebSocketServerLibrary.SimpleWebSocketServer._WebsocketHandler
private

Interface for the WebSocketHandler class.

Definition at line 17 of file SimpleWebsocketServer.cs.

◆ _WebSocketHttpServer

readonly IWebSocketHttpServer SimpleWebSocketServerLibrary.SimpleWebSocketServer._WebSocketHttpServer
private

Interface for the WebSocketHttpServer class.

Definition at line 21 of file SimpleWebsocketServer.cs.

Event Documentation

◆ WebsocketServerEvent

EventHandler<WebSocketEventArg> SimpleWebSocketServerLibrary.SimpleWebSocketServer.WebsocketServerEvent

Eventhandler for when events such as receiving messages and errors from the websocket server happen.

Definition at line 27 of file SimpleWebsocketServer.cs.


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