Skip to content

Full Documenation

Eldin Zenderink edited this page Jun 21, 2018 · 2 revisions

Summary

Members Descriptions
namespace SimpleWebsocketServer
namespace SimpleWebSocketServerLibrary
namespace SimpleWebSocketServerLibrary::SimpleWebSocketHandler
namespace SimpleWebSocketServerLibrary::SimpleWebSocketHttpServer
namespace SimpleWebSocketServerLibrary::WSocketServer

namespace SimpleWebsocketServer

Summary

Members Descriptions
class SimpleWebsocketServer::HttpServerSettings

class SimpleWebsocketServer::HttpServerSettings

Summary

Members Descriptions

Members

namespace SimpleWebSocketServerLibrary

Summary

Members Descriptions
class SimpleWebSocketServerLibrary::SimpleWebSocketServer Middleware class for interfacing with the WebSocketHandler and WebSocketHttpServer class.
class SimpleWebSocketServerLibrary::SimpleWebSocketServerSettings Provides settings and default values for the SimpleWebSocketServer Class.
class SimpleWebSocketServerLibrary::WebSocketClientInfo Provides information about a connected client.
class SimpleWebSocketServerLibrary::WebSocketEventArg Contains information about a occured event.
class SimpleWebSocketServerLibrary::WebSocketMessageContainer Contains information about a websocket client message.

class SimpleWebSocketServerLibrary::SimpleWebSocketServer

Middleware class for interfacing with the WebSocketHandler and WebSocketHttpServer class.

Summary

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

Members

Constructor for setting up the Library.

Parameters

  • settings Settings with default values.

public inline SimpleWebSocketServer()

Overload constructor for setting up library with default values.

public inline async Task StartServerAsync()

Starts running the server async.

public inline void StartServer()

Starts running the server async.

public inline async Task< bool > SendTextMessageAsync(string messageToSend,string clientId)

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

Parameters

  • messageToSend
  • clientId

Returns

True when send succesfully.

public inline bool SendTextMessage(string messageToSend,string clientId)

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

Parameters

  • messageToSend
  • clientId

Returns

True when send succesfully.

public inline async Task< bool > SendBinaryMessageAsync(byte [] messageToSend,string clientId)

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

Parameters

  • messageToSend Message in binary format (byte array).

  • clientId Client to send to.

Returns

True when succesfully send.

public inline bool SendBinaryMessage(byte [] messageToSend,string clientId)

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

Parameters

  • messageToSend Message in binary format (byte array).

  • clientId Client to send to.

Returns

True when succesfully send.

public inline async Task< bool > SendPingMessageAsync(string messageToSend,string clientId)

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

Parameters

  • messageToSend Possible extra message to send along ping.

  • clientId Set clientId in case you want to send to a specific client.

Returns

True when succesfully send.

public inline bool SendPingMessage(string messageToSend,string clientId)

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

Parameters

  • messageToSend Possible extra message to send along ping.

  • clientId Set clientId in case you want to send to a specific client.

Returns

True when succesfully send.

public inline async Task< bool > SendPongMessageAsync(string messageToSend,string clientId)

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

Parameters

  • messageToSend Possible extra message to send along ping.

  • clientId Set clientId in case you want to send to a specific client.

Returns

True when succesfully send.

public inline bool SendPongMessage(string messageToSend,string clientId)

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

Parameters

  • messageToSend Possible extra message to send along ping.

  • clientId Set clientId in case you want to send to a specific client.

Returns

True when succesfully send.

public inline async Task< bool > StopClientAsync(string clientId,string reason)

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

Parameters

  • clientId Specific client to close connection with.

  • reason Possible reason to close the connection.

Returns

True when succesfully closed.

public inline bool StopClient(string clientId,string reason)

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

Parameters

  • clientId Specific client to close connection with.

  • reason Possible reason to close the connection.

Returns

True when succesfully closed.

public inline async Task< bool > StopAllAsync(string reason)

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

Parameters

  • reason Possible reason to close the connection.

Returns

True when succesfully closed.

public inline bool StopAll(string reason)

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

Parameters

  • reason Possible reason to close the connection.

Returns

True when succesfully closed.

class SimpleWebSocketServerLibrary::SimpleWebSocketServerSettings

Provides settings and default values for the SimpleWebSocketServer Class.

Summary

Members Descriptions
{property} List< string > baseUrls List with url paths where the websocket server needs to listen to. Default = "";
{property} int port Port where the server needs to listen to. Default = 80;
{property} int bufferSize Buffer size for receiving messages. Default = 4096; (bytes)

Members

{property} List< string > baseUrls

List with url paths where the websocket server needs to listen to. Default = "";

{property} int port

Port where the server needs to listen to. Default = 80;

{property} int bufferSize

Buffer size for receiving messages. Default = 4096; (bytes)

class SimpleWebSocketServerLibrary::WebSocketClientInfo

Provides information about a connected client.

Summary

Members Descriptions
{property} TcpClient client TcpClient containing the socket handler.
{property} string clientId ClientID generated by the server or set by the client.
{property} string clientBaseUrl BaseURL client used to connect to.

Members

{property} TcpClient client

TcpClient containing the socket handler.

{property} string clientId

ClientID generated by the server or set by the client.

{property} string clientBaseUrl

BaseURL client used to connect to.

class SimpleWebSocketServerLibrary::WebSocketEventArg

class SimpleWebSocketServerLibrary::WebSocketEventArg
  : public EventArgs

Contains information about a occured event.

Summary

Members Descriptions
{property} bool isText Is true when message is a text message.
{property} bool isBinary Is true when message is a binairy message.
{property} bool isClosed Is true when a client send a close message.
{property} bool isOpen Is true when a client has connected
{property} bool isPing Is true when message from client is a ping message.
{property} bool isPong Is true when message from client is a pong message.
{property} byte [] data Contains the extra data send by a client.
{property} UInt64 messageLength Message length in bytes.
{property} string clientId Client ID set by client or generated by server when connecting to websocket server.
{property} string clientBaseUrl Client baseurl used when connecting.
{property} string errorMessage Error message in case an error occurred.

Members

{property} bool isText

Is true when message is a text message.

{property} bool isBinary

Is true when message is a binairy message.

{property} bool isClosed

Is true when a client send a close message.

{property} bool isOpen

Is true when a client has connected

{property} bool isPing

Is true when message from client is a ping message.

{property} bool isPong

Is true when message from client is a pong message.

{property} byte [] data

Contains the extra data send by a client.

{property} UInt64 messageLength

Message length in bytes.

{property} string clientId

Client ID set by client or generated by server when connecting to websocket server.

{property} string clientBaseUrl

Client baseurl used when connecting.

{property} string errorMessage

Error message in case an error occurred.

class SimpleWebSocketServerLibrary::WebSocketMessageContainer

Contains information about a websocket client message.

Summary

Members Descriptions
{property} bool isText Is true when message is a text message.
{property} bool isBinary Is true when message is a binairy message.
{property} bool isClosed Is true when a client send a close message.
{property} bool isPing Is true when message from client is a ping message.
{property} bool isPong Is true when message from client is a pong message.
{property} byte [] data Contains the extra data send by a client.

Members

{property} bool isText

Is true when message is a text message.

{property} bool isBinary

Is true when message is a binairy message.

{property} bool isClosed

Is true when a client send a close message.

{property} bool isPing

Is true when message from client is a ping message.

{property} bool isPong

Is true when message from client is a pong message.

{property} byte [] data

Contains the extra data send by a client.

namespace SimpleWebSocketServerLibrary::SimpleWebSocketHandler

Summary

Members Descriptions
class SimpleWebSocketServerLibrary::SimpleWebSocketHandler::WebSocketHandler Class contains handler for handeling multiple websocket clients and hubs.

class SimpleWebSocketServerLibrary::SimpleWebSocketHandler::WebSocketHandler

class SimpleWebSocketServerLibrary::SimpleWebSocketHandler::WebSocketHandler
  : public SimpleWebSocketServerLibrary.SimpleWebSocketHandler.IWebSocketHandler

Class contains handler for handeling multiple websocket clients and hubs.

Summary

Members Descriptions
public inline WebSocketHandler(int bufferSize) Constructor for websocket handler for automatic control of the websocket server.
public inline async void StartConnection(TcpClient client,string clientId,string baseUrl) Starts a connection given the settings set by caller.
public inline async Task< bool > StopClient(string clientId) Stops a connection with a specific client.
public inline async Task< bool > StopClient(string clientId,string reason) Stops a client while specifying a reason.
public inline async Task< bool > StopAll() Stops all connections.
public inline async Task< bool > StopAll(string reason) Stops all connections and provides a reason to the clients.
public inline async Task< bool > SendMessage(WebSocketMessageContainer message,string clientId) Send a message to a specific client.
public inline async Task< bool > SendMessage(WebSocketMessageContainer message) Sends a message to all connected clients.
public inline void OnWebsocketEvent(object sender,WebSocketEventArg arg) WebSocket Server event handler, fires the event.

Members

public inline WebSocketHandler(int bufferSize)

Constructor for websocket handler for automatic control of the websocket server.

Parameters

  • bufferSize Sets the receive buffer size, default = 4096 bytes (Messages received larger than buffer will be cut off/incomplete).

public inline async void StartConnection(TcpClient client,string clientId,string baseUrl)

Starts a connection given the settings set by caller.

Parameters

  • client TcpClient socket handler.

  • stream NetworkStream stream handler.

  • clientId Id of client.

  • baseUrl URL path used by client.

public inline async Task< bool > StopClient(string clientId)

Stops a connection with a specific client.

Parameters

  • clientId Id of client of which to stop the connection with.

Returns

True on success.

public inline async Task< bool > StopClient(string clientId,string reason)

Stops a client while specifying a reason.

Parameters

  • clientId Id of client of which to stop the connection with.

  • reason Reason to send to client.

Returns

True on success.

public inline async Task< bool > StopAll()

Stops all connections.

Returns

True on success.

public inline async Task< bool > StopAll(string reason)

Stops all connections and provides a reason to the clients.

Parameters

  • reason Reason for disconnect.

Returns

True on success.

public inline async Task< bool > SendMessage(WebSocketMessageContainer message,string clientId)

Send a message to a specific client.

Parameters

  • message Message container containing everything related to the message.

  • clientId Id of the client to send the message to.

Returns

True on success.

public inline async Task< bool > SendMessage(WebSocketMessageContainer message)

Sends a message to all connected clients.

Parameters

  • message Message container containing everything related to the message.

Returns

True on success.

public inline void OnWebsocketEvent(object sender,WebSocketEventArg arg)

WebSocket Server event handler, fires the event.

Parameters

  • arg Arguments containing event arguments.

namespace SimpleWebSocketServerLibrary::SimpleWebSocketHttpServer

Summary

Members Descriptions
class SimpleWebSocketServerLibrary::SimpleWebSocketHttpServer::WebSocketHttpServer Runs the http server where a client needs to connect to.

class SimpleWebSocketServerLibrary::SimpleWebSocketHttpServer::WebSocketHttpServer

class SimpleWebSocketServerLibrary::SimpleWebSocketHttpServer::WebSocketHttpServer
  : public SimpleWebSocketServerLibrary.SimpleWebSocketHttpServer.IWebSocketHttpServer

Runs the http server where a client needs to connect to.

Summary

Members Descriptions
public inline WebSocketHttpServer(IWebSocketHandler websocketHandler,SimpleWebSocketServerSettings settings) Base constructor for setting up a HttpServer to provide the endpoint to where a WebSocket can connect to.
public inline string CheckIfBaseUrl(string toCheck) Checks if given url path is one of the base paths, it ignores it otherwise.
public inline string CheckIfCustomIdIsSet(string baseUrl,string fullBaseUrl) Checks if the url used by the client contains more than the baseurl, which will be used as a customid.
public inline byte [] GenerateAcceptResponse(string webSocketKey) Generates the response header for a websocket upgrade.
public inline async Task RunServer() Runs the http server inside a async task.
public inline void Stop() Stops the http server.

Members

public inline WebSocketHttpServer(IWebSocketHandler websocketHandler,SimpleWebSocketServerSettings settings)

Base constructor for setting up a HttpServer to provide the endpoint to where a WebSocket can connect to.

Parameters

  • websocketHandler WebSocket Handler instance.

  • settings Settings for the http server.

public inline string CheckIfBaseUrl(string toCheck)

Checks if given url path is one of the base paths, it ignores it otherwise.

Parameters

  • toCheck Path to check.

Returns

String with the basepath if given string is the same, otherwise null.

public inline string CheckIfCustomIdIsSet(string baseUrl,string fullBaseUrl)

Checks if the url used by the client contains more than the baseurl, which will be used as a customid.

Parameters

  • baseUrl
  • fullBaseUrl

Returns

string with id if there is one, else null

public inline byte [] GenerateAcceptResponse(string webSocketKey)

Generates the response header for a websocket upgrade.

Parameters

  • webSocketKey Key from client.

Returns

Byte array with response header.

public inline async Task RunServer()

Runs the http server inside a async task.

Returns

public inline void Stop()

Stops the http server.

namespace SimpleWebSocketServerLibrary::WSocketServer

Summary

Members Descriptions
class SimpleWebSocketServerLibrary::WSocketServer::WebSocketServer Runs the websocket server to communicate with a client.

class SimpleWebSocketServerLibrary::WSocketServer::WebSocketServer

Runs the websocket server to communicate with a client.

Summary

Members Descriptions
public inline WebSocketServer(WebSocketClientInfo clientInfo,int bufferSize) Start a websocket server.
public inline bool SendMessage(WebSocketMessageContainer message) Sends a websocket framed message to the client synchronous.
public inline async Task< bool > SendMessageAsync(WebSocketMessageContainer message) Sends a websocket framed message to the client asynchronous.
public inline bool StopServer(string reason) Stops the websocket server and sends over a reason synchronous.
public inline async Task< bool > StopServerAsync(string reason) Stops the websocket server and sends over a reason asynchronous.
public inline async Task StartServerAsync() Starts the WebSocket server / connection with the client asynchronous.
public inline void StartServer() Starts the WebSocket server / connection with the client synchronous.

Members

public inline WebSocketServer(WebSocketClientInfo clientInfo,int bufferSize)

Start a websocket server.

Parameters

  • bufferSize Sets the receive buffer size, default = 4096

  • clientInfo Sets the client information.

  • handler Sets the websocket handler.

public inline bool SendMessage(WebSocketMessageContainer message)

Sends a websocket framed message to the client synchronous.

Parameters

  • message Message container containing all the information needed for the message.

Returns

True on success.

public inline async Task< bool > SendMessageAsync(WebSocketMessageContainer message)

Sends a websocket framed message to the client asynchronous.

Parameters

  • message Message container containing all the information needed for the message.

Returns

True on success.

public inline bool StopServer(string reason)

Stops the websocket server and sends over a reason synchronous.

Parameters

  • reason Overload parameter for reason.

Returns

True on success.

public inline async Task< bool > StopServerAsync(string reason)

Stops the websocket server and sends over a reason asynchronous.

Parameters

  • reason Overload parameter for reason.

Returns

True on success.

public inline async Task StartServerAsync()

Starts the WebSocket server / connection with the client asynchronous.

Returns

public inline void StartServer()

Starts the WebSocket server / connection with the client synchronous.

Returns

Generated by Moxygen

Clone this wiki locally