-
Notifications
You must be signed in to change notification settings - Fork 2
Full Documenation
Members | Descriptions |
---|---|
namespace SimpleWebsocketServer
|
|
namespace SimpleWebSocketServerLibrary
|
|
namespace SimpleWebSocketServerLibrary::SimpleWebSocketHandler
|
|
namespace SimpleWebSocketServerLibrary::SimpleWebSocketHttpServer
|
|
namespace SimpleWebSocketServerLibrary::WSocketServer
|
Members | Descriptions |
---|---|
class SimpleWebsocketServer::HttpServerSettings
|
Members | Descriptions |
---|
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. |
Middleware class for interfacing with the WebSocketHandler and WebSocketHttpServer class.
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. |
public inline
SimpleWebSocketServer
(
SimpleWebSocketServerSettings
settings)
Constructor for setting up the Library.
-
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.
messageToSend
clientId
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.
messageToSend
clientId
True when send succesfully.
public inline async Task< bool >
SendBinaryMessageAsync
(byte [] messageToSend,string clientId)
Sends a binary "message" to a specific client asynchronous.
-
messageToSend
Message in binary format (byte array). -
clientId
Client to send to.
True when succesfully send.
public inline bool
SendBinaryMessage
(byte [] messageToSend,string clientId)
Sends a binary "message" to a specific client synchronous.
-
messageToSend
Message in binary format (byte array). -
clientId
Client to send to.
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.
-
messageToSend
Possible extra message to send along ping. -
clientId
Set clientId in case you want to send to a specific client.
True when succesfully send.
public inline bool
SendPingMessage
(string messageToSend,string clientId)
Sends a ping message to all clients synchronous, can have message.
-
messageToSend
Possible extra message to send along ping. -
clientId
Set clientId in case you want to send to a specific client.
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.
-
messageToSend
Possible extra message to send along ping. -
clientId
Set clientId in case you want to send to a specific client.
True when succesfully send.
public inline bool
SendPongMessage
(string messageToSend,string clientId)
Send pong message to all available clients synchronous, can have message.
-
messageToSend
Possible extra message to send along ping. -
clientId
Set clientId in case you want to send to a specific client.
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.
-
clientId
Specific client to close connection with. -
reason
Possible reason to close the connection.
True when succesfully closed.
public inline bool
StopClient
(string clientId,string reason)
Stops a connection with a specific client synchronous. Can provide reason.
-
clientId
Specific client to close connection with. -
reason
Possible reason to close the connection.
True when succesfully closed.
public inline async Task< bool >
StopAllAsync
(string reason)
Stops all connections with all clients asynchronous. Can provide reason.
-
reason
Possible reason to close the connection.
True when succesfully closed.
public inline bool
StopAll
(string reason)
Stops all connections with all clients synchronous. Can provide reason.
-
reason
Possible reason to close the connection.
True when succesfully closed.
Provides settings and default values for the SimpleWebSocketServer Class.
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) |
{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)
Provides information about a connected client.
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. |
{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
: public EventArgs
Contains information about a occured event.
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. |
{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.
Contains information about a websocket client message.
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. |
{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 | Descriptions |
---|---|
class SimpleWebSocketServerLibrary::SimpleWebSocketHandler::WebSocketHandler
|
Class contains handler for handeling multiple websocket clients and hubs. |
class SimpleWebSocketServerLibrary::SimpleWebSocketHandler::WebSocketHandler
: public SimpleWebSocketServerLibrary.SimpleWebSocketHandler.IWebSocketHandler
Class contains handler for handeling multiple websocket clients and hubs.
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. |
public inline
WebSocketHandler
(int bufferSize)
Constructor for websocket handler for automatic control of the websocket server.
-
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.
-
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.
-
clientId
Id of client of which to stop the connection with.
True on success.
public inline async Task< bool >
StopClient
(string clientId,string reason)
Stops a client while specifying a reason.
-
clientId
Id of client of which to stop the connection with. -
reason
Reason to send to client.
True on success.
public inline async Task< bool >
StopAll
()
Stops all connections.
True on success.
public inline async Task< bool >
StopAll
(string reason)
Stops all connections and provides a reason to the clients.
-
reason
Reason for disconnect.
True on success.
public inline async Task< bool >
SendMessage
(
WebSocketMessageContainer
message,string clientId)
Send a message to a specific client.
-
message
Message container containing everything related to the message. -
clientId
Id of the client to send the message to.
True on success.
public inline async Task< bool >
SendMessage
(
WebSocketMessageContainer
message)
Sends a message to all connected clients.
-
message
Message container containing everything related to the message.
True on success.
public inline void
OnWebsocketEvent
(object sender,
WebSocketEventArg
arg)
WebSocket Server event handler, fires the event.
-
arg
Arguments containing event arguments.
Members | Descriptions |
---|---|
class SimpleWebSocketServerLibrary::SimpleWebSocketHttpServer::WebSocketHttpServer
|
Runs the http server where a client needs to connect to. |
class SimpleWebSocketServerLibrary::SimpleWebSocketHttpServer::WebSocketHttpServer
: public SimpleWebSocketServerLibrary.SimpleWebSocketHttpServer.IWebSocketHttpServer
Runs the http server where a client needs to connect to.
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. |
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.
-
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.
-
toCheck
Path to check.
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.
baseUrl
fullBaseUrl
string with id if there is one, else null
public inline byte []
GenerateAcceptResponse
(string webSocketKey)
Generates the response header for a websocket upgrade.
-
webSocketKey
Key from client.
Byte array with response header.
public inline async Task
RunServer
()
Runs the http server inside a async task.
public inline void
Stop
()
Stops the http server.
Members | Descriptions |
---|---|
class SimpleWebSocketServerLibrary::WSocketServer::WebSocketServer
|
Runs the websocket server to communicate with a client. |
Runs the websocket server to communicate with a client.
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. |
public inline
WebSocketServer
(
WebSocketClientInfo
clientInfo,int bufferSize)
Start a websocket server.
-
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.
-
message
Message container containing all the information needed for the message.
True on success.
public inline async Task< bool >
SendMessageAsync
(
WebSocketMessageContainer
message)
Sends a websocket framed message to the client asynchronous.
-
message
Message container containing all the information needed for the message.
True on success.
public inline bool
StopServer
(string reason)
Stops the websocket server and sends over a reason synchronous.
-
reason
Overload parameter for reason.
True on success.
public inline async Task< bool >
StopServerAsync
(string reason)
Stops the websocket server and sends over a reason asynchronous.
-
reason
Overload parameter for reason.
True on success.
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.
Generated by Moxygen