Class WebSocketConnection
Represents a connection to a WebSocket.
public class WebSocketConnection : IWebSocketConnection
- Inheritance
-
WebSocketConnection
- Implements
- Inherited Members
Constructors
WebSocketConnection(ISocket, string)
Initializes a new instance of the WebSocketConnection class.
public WebSocketConnection(ISocket socket, string parseScheme)
Parameters
socketISocketThe ISocket used in the connection.
parseSchemestringThe scheme used to parse requests.
Properties
ConnectionInfo
Gets an IWebSocketConnectionInfo object describing the connection.
public IWebSocketConnectionInfo ConnectionInfo { get; }
Property Value
Handler
Gets or sets the IHandler implementation used for parsing and handling requests.
public IHandler Handler { get; set; }
Property Value
Socket
Gets or sets the ISocket implementation used for communication.
public ISocket Socket { get; set; }
Property Value
Methods
Close()
Closes the connection.
public void Close()
OnBinaryMessageReceived(BinaryMessageHandledEventArgs)
Fires the BinaryMessageReceived event.
protected void OnBinaryMessageReceived(BinaryMessageHandledEventArgs e)
Parameters
eBinaryMessageHandledEventArgsA BinaryMessageHandledEventArgs that contains the event data.
OnClose(ConnectionEventArgs)
Fires the Closed event.
protected void OnClose(ConnectionEventArgs e)
Parameters
eConnectionEventArgsA ConnectionEventArgs that contains the event data.
OnError(ErrorEventArgs)
Fires the ErrorReceived event.
protected void OnError(ErrorEventArgs e)
Parameters
eErrorEventArgsAn ErrorEventArgs that contains the event data.
OnMessageReceived(TextMessageHandledEventArgs)
Fires the MessageReceived event.
protected void OnMessageReceived(TextMessageHandledEventArgs e)
Parameters
eTextMessageHandledEventArgsA TextMessageHandledEventArgs that contains the event data.
OnOpen(ConnectionEventArgs)
Fires the Opened event.
protected void OnOpen(ConnectionEventArgs e)
Parameters
eConnectionEventArgsA ConnectionEventArgs that contains the event data.
OnSend(EventArgs)
Fires the Sent event.
protected void OnSend(EventArgs e)
Parameters
OnStandardHttpRequestReceived(StandardHttpRequestReceivedEventArgs)
Fires the StandardHttpRequestReceived event.
protected void OnStandardHttpRequestReceived(StandardHttpRequestReceivedEventArgs e)
Parameters
eStandardHttpRequestReceivedEventArgsA StandardHttpRequestReceivedEventArgs that contains the event data.
Send(byte[])
Sends a binary message over the connection.
public void Send(byte[] message)
Parameters
messagebyte[]The binary message to send.
Send(string)
Sends a text message over the connection.
public void Send(string message)
Parameters
messagestringThe text message to send.
SendRaw(string)
Sends raw text over the connection, without passing through a handler.
public void SendRaw(string message)
Parameters
messagestringThe message to send.
StartReceiving()
Starts the connection receiving requests.
public void StartReceiving()
Events
BinaryMessageReceived
Event raised when a binary message is received via the connection.
public event EventHandler<BinaryMessageHandledEventArgs> BinaryMessageReceived
Event Type
Closed
Event raised when a connection is closed.
public event EventHandler<ConnectionEventArgs> Closed
Event Type
ErrorReceived
Event raised when an error occurs via the connection.
public event EventHandler<ErrorEventArgs> ErrorReceived
Event Type
MessageReceived
Event raised when a text message is received via the connection.
public event EventHandler<TextMessageHandledEventArgs> MessageReceived
Event Type
Opened
Event raised when a connection is opened.
public event EventHandler<ConnectionEventArgs> Opened
Event Type
Sent
Event raised when data is sent via the connection.
public event EventHandler Sent
Event Type
StandardHttpRequestReceived
Event raised when a non-WebSocket message is received.
public event EventHandler<StandardHttpRequestReceivedEventArgs> StandardHttpRequestReceived