Class WebSocketServer
Provides an implementation of a WebSocket server.
public class WebSocketServer : IWebSocketServer, IDisposable
- Inheritance
-
WebSocketServer
- Implements
- Inherited Members
Constructors
WebSocketServer(int, string)
Initializes a new instance of the WebSocketServer class.
public WebSocketServer(int port, string location)
Parameters
port
intThe port on which to listen for connections.
location
stringThe location at which to listen for connections.
WebSocketServer(string)
Initializes a new instance of the WebSocketServer class.
public WebSocketServer(string location)
Parameters
location
stringThe location at which to listen for connections.
Properties
Certificate
Gets or sets the certificate used for authentication.
public string Certificate { get; set; }
Property Value
IsSecure
Gets a value indicating whether the connection is secure.
public bool IsSecure { get; }
Property Value
ListenerSocket
Gets or sets the ISocket on which communication occurs.
public ISocket ListenerSocket { get; set; }
Property Value
Location
Gets the location the server is listening on for connections.
public string Location { get; }
Property Value
Port
Gets the port the server is listening on for connections.
public int Port { get; }
Property Value
Methods
Dispose()
Releases all resources used by the WebSocketServer.
public void Dispose()
Dispose(bool)
Releases the unmanaged resources used by the SocketWrapper and optionally releases the managed resources.
protected virtual void Dispose(bool disposing)
Parameters
OnConnectionClosed(ConnectionEventArgs)
Raises the ConnectionClosed event.
protected void OnConnectionClosed(ConnectionEventArgs e)
Parameters
e
ConnectionEventArgsA ConnectionEventArgs that contains the event data.
OnConnectionOpened(ConnectionEventArgs)
Raises the ConnectionOpened event.
protected void OnConnectionOpened(ConnectionEventArgs e)
Parameters
e
ConnectionEventArgsA ConnectionEventArgs that contains the event data.
OnErrorOccurred(ErrorEventArgs)
Raises the ErrorOccurred event.
protected void OnErrorOccurred(ErrorEventArgs e)
Parameters
e
ErrorEventArgsAn ErrorEventArgs that contains the event data.
OnMessageReceived(TextMessageHandledEventArgs)
Raises the MessageReceived event.
protected void OnMessageReceived(TextMessageHandledEventArgs e)
Parameters
e
TextMessageHandledEventArgsA TextMessageHandledEventArgs that contains the event data.
OnStandardHttpRequestReceived(StandardHttpRequestReceivedEventArgs)
Raises the StandardHttpRequestReceived event.
protected void OnStandardHttpRequestReceived(StandardHttpRequestReceivedEventArgs e)
Parameters
e
StandardHttpRequestReceivedEventArgsA StandardHttpRequestReceivedEventArgs that contains the event data.
Start()
Starts the server.
public void Start()
Events
Closed
Event raised when a connection is closed.
public event EventHandler<ConnectionEventArgs> Closed
Event Type
ErrorOccurred
Event raised when an error occurs.
public event EventHandler<ErrorEventArgs> ErrorOccurred
Event Type
MessageReceived
Event raised when a message is received from the WebSocket.
public event EventHandler<TextMessageHandledEventArgs> MessageReceived
Event Type
Opened
Event raised when a connection is opened.
public event EventHandler<ConnectionEventArgs> Opened
Event Type
StandardHttpRequestReceived
Event raised when a non-WebSocket message is received.
public event EventHandler<StandardHttpRequestReceivedEventArgs> StandardHttpRequestReceived