#region License
/*
* WebSocketBehavior.cs
*
* The MIT License
*
* Copyright (c) 2012-2025 sta.blockhead
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#endregion
using System;
using System.Collections.Specialized;
using System.IO;
using System.Security.Principal;
using WebSocketSharp.Net;
using WebSocketSharp.Net.WebSockets;
namespace WebSocketSharp.Server
{
///
/// Exposes a set of methods and properties used to define the behavior of
/// a WebSocket service provided by the or
/// class.
///
///
/// This class is an abstract class.
///
public abstract class WebSocketBehavior : IWebSocketSession
{
#region Private Fields
private WebSocketContext _context;
private Func _cookiesValidator;
private bool _emitOnPing;
private Func _hostValidator;
private string _id;
private bool _ignoreExtensions;
private bool _noDelay;
private Func _originValidator;
private string _protocol;
private WebSocketSessionManager _sessions;
private DateTime _startTime;
private WebSocket _websocket;
#endregion
#region Protected Constructors
///
/// Initializes a new instance of the class.
///
protected WebSocketBehavior ()
{
_startTime = DateTime.MaxValue;
}
#endregion
#region Protected Properties
///
/// Gets the HTTP headers for a session.
///
///
/// A that contains the headers
/// included in the WebSocket handshake request.
///
///
/// The get operation is not available when the session has not started yet.
///
protected NameValueCollection Headers {
get {
if (_context == null) {
var msg = "The get operation is not available.";
throw new InvalidOperationException (msg);
}
return _context.Headers;
}
}
///
/// Gets a value indicating whether the communication is possible for
/// a session.
///
///
/// true if the communication is possible; otherwise, false.
///
///
/// The get operation is not available when the session has not started yet.
///
protected bool IsAlive {
get {
if (_websocket == null) {
var msg = "The get operation is not available.";
throw new InvalidOperationException (msg);
}
return _websocket.IsAlive;
}
}
///
/// Gets the query string for a session.
///
///
///
/// A that contains the query
/// parameters included in the WebSocket handshake request.
///
///
/// An empty collection if not included.
///
///
///
/// The get operation is not available when the session has not started yet.
///
protected NameValueCollection QueryString {
get {
if (_context == null) {
var msg = "The get operation is not available.";
throw new InvalidOperationException (msg);
}
return _context.QueryString;
}
}
///
/// Gets the current state of the WebSocket interface for a session.
///
///
///
/// One of the enum values.
///
///
/// It indicates the current state of the interface.
///
///
///
/// The get operation is not available when the session has not started yet.
///
protected WebSocketState ReadyState {
get {
if (_websocket == null) {
var msg = "The get operation is not available.";
throw new InvalidOperationException (msg);
}
return _websocket.ReadyState;
}
}
///
/// Gets the management function for the sessions in the service.
///
///
/// A that manages the sessions in
/// the service.
///
///
/// The get operation is not available when the session has not started yet.
///
protected WebSocketSessionManager Sessions {
get {
if (_sessions == null) {
var msg = "The get operation is not available.";
throw new InvalidOperationException (msg);
}
return _sessions;
}
}
///
/// Gets the client information for a session.
///
///
///
/// A instance that represents identity,
/// authentication, and security roles for the client.
///
///
/// if the client is not authenticated.
///
///
///
/// The get operation is not available when the session has not started yet.
///
protected IPrincipal User {
get {
if (_context == null) {
var msg = "The get operation is not available.";
throw new InvalidOperationException (msg);
}
return _context.User;
}
}
///
/// Gets the client endpoint for a session.
///
///
/// A that represents the client
/// IP address and port number.
///
///
/// The get operation is not available when the session has not started yet.
///
protected System.Net.IPEndPoint UserEndPoint {
get {
if (_context == null) {
var msg = "The get operation is not available.";
throw new InvalidOperationException (msg);
}
return _context.UserEndPoint;
}
}
#endregion
#region Public Properties
///
/// Gets or sets the delegate used to validate the HTTP cookies.
///
///
///
/// A
/// delegate.
///
///
/// It represents the delegate called when the WebSocket interface
/// for a session validates the handshake request.
///
///
/// 1st parameter passed to the delegate
/// contains the cookies to validate.
///
///
/// 2nd parameter passed to the delegate
/// holds the cookies to send to the client.
///
///
/// The method invoked by the delegate must return true
/// if the cookies are valid.
///
///
/// if not necessary.
///
///
/// The default value is .
///
///
///
/// The set operation is not available when the session has already started.
///
public Func CookiesValidator {
get {
return _cookiesValidator;
}
set {
if (_websocket != null) {
var msg = "The set operation is not available.";
throw new InvalidOperationException (msg);
}
_cookiesValidator = value;
}
}
///
/// Gets or sets a value indicating whether the WebSocket interface for
/// a session emits the message event when it receives a ping.
///
///
///
/// true if the interface emits the message event when it receives
/// a ping; otherwise, false.
///
///
/// The default value is false.
///
///
///
/// The set operation is not available when the session has already started.
///
public bool EmitOnPing {
get {
return _emitOnPing;
}
set {
if (_websocket != null) {
var msg = "The set operation is not available.";
throw new InvalidOperationException (msg);
}
_emitOnPing = value;
}
}
///
/// Gets or sets the delegate used to validate the Host header.
///
///
///
/// A delegate.
///
///
/// It represents the delegate called when the WebSocket interface
/// for a session validates the handshake request.
///
///
/// The parameter passed to the delegate is
/// the value of the Host header.
///
///
/// The method invoked by the delegate must return true
/// if the header value is valid.
///
///
/// if not necessary.
///
///
/// The default value is .
///
///
///
/// The set operation is not available when the session has already started.
///
public Func HostValidator {
get {
return _hostValidator;
}
set {
if (_websocket != null) {
var msg = "The set operation is not available.";
throw new InvalidOperationException (msg);
}
_hostValidator = value;
}
}
///
/// Gets the unique ID of a session.
///
///
///
/// A that represents the unique ID of the session.
///
///
/// when the session has not started yet.
///
///
public string ID {
get {
return _id;
}
}
///
/// Gets or sets a value indicating whether the WebSocket interface for
/// a session ignores the Sec-WebSocket-Extensions header.
///
///
///
/// true if the interface ignores the extensions requested
/// from the client; otherwise, false.
///
///
/// The default value is false.
///
///
///
/// The set operation is not available when the session has already started.
///
public bool IgnoreExtensions {
get {
return _ignoreExtensions;
}
set {
if (_websocket != null) {
var msg = "The set operation is not available.";
throw new InvalidOperationException (msg);
}
_ignoreExtensions = value;
}
}
///
/// Gets or sets a value indicating whether the underlying TCP socket of
/// the WebSocket interface for a session disables a delay when send or
/// receive buffer is not full.
///
///
///
/// true if the delay is disabled; otherwise, false.
///
///
/// The default value is false.
///
///
///
///
/// The set operation is not available when the session has already started.
///
public bool NoDelay {
get {
return _noDelay;
}
set {
if (_websocket != null) {
var msg = "The set operation is not available.";
throw new InvalidOperationException (msg);
}
_noDelay = value;
}
}
///
/// Gets or sets the delegate used to validate the Origin header.
///
///
///
/// A delegate.
///
///
/// It represents the delegate called when the WebSocket interface
/// for a session validates the handshake request.
///
///
/// The parameter passed to the delegate is
/// the value of the Origin header or if
/// the header is not present.
///
///
/// The method invoked by the delegate must return true
/// if the header value is valid.
///
///
/// if not necessary.
///
///
/// The default value is .
///
///
///
/// The set operation is not available when the session has already started.
///
public Func OriginValidator {
get {
return _originValidator;
}
set {
if (_websocket != null) {
var msg = "The set operation is not available.";
throw new InvalidOperationException (msg);
}
_originValidator = value;
}
}
///
/// Gets or sets the name of the WebSocket subprotocol for a session.
///
///
///
/// A that represents the name of the subprotocol.
///
///
/// The value specified for a set operation must be a token defined in
///
/// RFC 2616.
///
///
/// The value is initialized if not requested.
///
///
/// The default value is an empty string.
///
///
///
/// The value specified for a set operation is not a token.
///
///
/// The set operation is not available when the session has already started.
///
public string Protocol {
get {
return _websocket != null
? _websocket.Protocol
: (_protocol ?? String.Empty);
}
set {
if (_websocket != null) {
var msg = "The set operation is not available.";
throw new InvalidOperationException (msg);
}
if (value == null || value.Length == 0) {
_protocol = null;
return;
}
if (!value.IsToken ()) {
var msg = "Not a token.";
throw new ArgumentException (msg, "value");
}
_protocol = value;
}
}
///
/// Gets the time that a session has started.
///
///
///
/// A that represents the time that the session
/// has started.
///
///
/// when the session has not started yet.
///
///
public DateTime StartTime {
get {
return _startTime;
}
}
#endregion
#region Private Methods
private string checkHandshakeRequest (WebSocketContext context)
{
if (_hostValidator != null) {
if (!_hostValidator (context.Host)) {
var msg = "The Host header is invalid.";
return msg;
}
}
if (_originValidator != null) {
if (!_originValidator (context.Origin)) {
var msg = "The Origin header is non-existent or invalid.";
return msg;
}
}
if (_cookiesValidator != null) {
var req = context.CookieCollection;
var res = context.WebSocket.CookieCollection;
if (!_cookiesValidator (req, res)) {
var msg = "The Cookie header is non-existent or invalid.";
return msg;
}
}
return null;
}
private void onClose (object sender, CloseEventArgs e)
{
if (_id == null)
return;
_sessions.Remove (_id);
OnClose (e);
}
private void onError (object sender, ErrorEventArgs e)
{
OnError (e);
}
private void onMessage (object sender, MessageEventArgs e)
{
OnMessage (e);
}
private void onOpen (object sender, EventArgs e)
{
_id = _sessions.Add (this);
if (_id == null) {
_websocket.Close (CloseStatusCode.Away);
return;
}
_startTime = DateTime.Now;
OnOpen ();
}
#endregion
#region Internal Methods
internal void Start (
WebSocketContext context,
WebSocketSessionManager sessions
)
{
_context = context;
_sessions = sessions;
_websocket = context.WebSocket;
_websocket.CustomHandshakeRequestChecker = checkHandshakeRequest;
if (_emitOnPing)
_websocket.EmitOnPing = true;
if (_ignoreExtensions)
_websocket.IgnoreExtensions = true;
if (_noDelay)
_websocket.NoDelay = true;
if (_protocol != null)
_websocket.Protocol = _protocol;
var waitTime = sessions.WaitTime;
if (waitTime != _websocket.WaitTime)
_websocket.WaitTime = waitTime;
_websocket.OnClose += onClose;
_websocket.OnError += onError;
_websocket.OnMessage += onMessage;
_websocket.OnOpen += onOpen;
_websocket.Accept ();
}
#endregion
#region Protected Methods
///
/// Closes the WebSocket connection for a session.
///
///
/// This method does nothing when the current state of the WebSocket
/// interface is Closing or Closed.
///
///
/// The Close method is not available when the session has not started yet.
///
protected void Close ()
{
if (_websocket == null) {
var msg = "The Close method is not available.";
throw new InvalidOperationException (msg);
}
_websocket.Close ();
}
///
/// Closes the WebSocket connection for a session with the specified
/// status code and reason.
///
///
/// This method does nothing when the current state of the WebSocket
/// interface is Closing or Closed.
///
///
///
/// A that specifies the status code indicating
/// the reason for the close.
///
///
/// The status codes are defined in
///
/// Section 7.4 of RFC 6455.
///
///
///
///
/// A that specifies the reason for the close.
///
///
/// Its size must be 123 bytes or less in UTF-8.
///
///
///
///
/// is 1010 (mandatory extension).
///
///
/// -or-
///
///
/// is 1005 (no status) and
/// is specified.
///
///
/// -or-
///
///
/// could not be UTF-8-encoded.
///
///
///
///
/// is less than 1000 or greater than 4999.
///
///
/// -or-
///
///
/// The size of is greater than 123 bytes.
///
///
///
/// The Close method is not available when the session has not started yet.
///
protected void Close (ushort code, string reason)
{
if (_websocket == null) {
var msg = "The Close method is not available.";
throw new InvalidOperationException (msg);
}
_websocket.Close (code, reason);
}
///
/// Closes the WebSocket connection for a session with the specified
/// status code and reason.
///
///
/// This method does nothing when the current state of the WebSocket
/// interface is Closing or Closed.
///
///
///
/// One of the enum values.
///
///
/// It specifies the status code indicating the reason for the close.
///
///
///
///
/// A that specifies the reason for the close.
///
///
/// Its size must be 123 bytes or less in UTF-8.
///
///
///
///
/// is an undefined enum value.
///
///
/// -or-
///
///
/// is .
///
///
/// -or-
///
///
/// is and
/// is specified.
///
///
/// -or-
///
///
/// could not be UTF-8-encoded.
///
///
///
/// The size of is greater than 123 bytes.
///
///
/// The Close method is not available when the session has not started yet.
///
protected void Close (CloseStatusCode code, string reason)
{
if (_websocket == null) {
var msg = "The Close method is not available.";
throw new InvalidOperationException (msg);
}
_websocket.Close (code, reason);
}
///
/// Closes the WebSocket connection for a session asynchronously.
///
///
///
/// This method does not wait for the close to be complete.
///
///
/// This method does nothing when the current state of the WebSocket
/// interface is Closing or Closed.
///
///
///
/// The CloseAsync method is not available when the session has not
/// started yet.
///
protected void CloseAsync ()
{
if (_websocket == null) {
var msg = "The CloseAsync method is not available.";
throw new InvalidOperationException (msg);
}
_websocket.CloseAsync ();
}
///
/// Closes the WebSocket connection for a session asynchronously with
/// the specified status code and reason.
///
///
///
/// This method does not wait for the close to be complete.
///
///
/// This method does nothing when the current state of the WebSocket
/// interface is Closing or Closed.
///
///
///
///
/// A that specifies the status code indicating
/// the reason for the close.
///
///
/// The status codes are defined in
///
/// Section 7.4 of RFC 6455.
///
///
///
///
/// A that specifies the reason for the close.
///
///
/// Its size must be 123 bytes or less in UTF-8.
///
///
///
///
/// is 1010 (mandatory extension).
///
///
/// -or-
///
///
/// is 1005 (no status) and
/// is specified.
///
///
/// -or-
///
///
/// could not be UTF-8-encoded.
///
///
///
///
/// is less than 1000 or greater than 4999.
///
///
/// -or-
///
///
/// The size of is greater than 123 bytes.
///
///
///
/// The CloseAsync method is not available when the session has not
/// started yet.
///
protected void CloseAsync (ushort code, string reason)
{
if (_websocket == null) {
var msg = "The CloseAsync method is not available.";
throw new InvalidOperationException (msg);
}
_websocket.CloseAsync (code, reason);
}
///
/// Closes the WebSocket connection for a session asynchronously with
/// the specified status code and reason.
///
///
///
/// This method does not wait for the close to be complete.
///
///
/// This method does nothing when the current state of the WebSocket
/// interface is Closing or Closed.
///
///
///
///
/// One of the enum values.
///
///
/// It specifies the status code indicating the reason for the close.
///
///
///
///
/// A that specifies the reason for the close.
///
///
/// Its size must be 123 bytes or less in UTF-8.
///
///
///
///
/// is an undefined enum value.
///
///
/// -or-
///
///
/// is .
///
///
/// -or-
///
///
/// is and
/// is specified.
///
///
/// -or-
///
///
/// could not be UTF-8-encoded.
///
///
///
/// The size of is greater than 123 bytes.
///
///
/// The CloseAsync method is not available when the session has not
/// started yet.
///
protected void CloseAsync (CloseStatusCode code, string reason)
{
if (_websocket == null) {
var msg = "The CloseAsync method is not available.";
throw new InvalidOperationException (msg);
}
_websocket.CloseAsync (code, reason);
}
///
/// Called when the WebSocket connection for a session has been closed.
///
///
/// A that represents the event data passed
/// from a event.
///
protected virtual void OnClose (CloseEventArgs e)
{
}
///
/// Called when the WebSocket interface for a session gets an error.
///
///
/// A that represents the event data passed
/// from a event.
///
protected virtual void OnError (ErrorEventArgs e)
{
}
///
/// Called when the WebSocket interface for a session receives a message.
///
///
/// A that represents the event data passed
/// from a event.
///
protected virtual void OnMessage (MessageEventArgs e)
{
}
///
/// Called when the WebSocket connection for a session has been established.
///
protected virtual void OnOpen ()
{
}
///
/// Sends a ping to the client for a session.
///
///
/// true if the send has successfully done and a pong has been
/// received within a time; otherwise, false.
///
///
/// The Ping method is not available when the session has not started yet.
///
protected bool Ping ()
{
if (_websocket == null) {
var msg = "The Ping method is not available.";
throw new InvalidOperationException (msg);
}
return _websocket.Ping ();
}
///
/// Sends a ping with the specified message to the client for a session.
///
///
/// true if the send has successfully done and a pong has been
/// received within a time; otherwise, false.
///
///
///
/// A that specifies the message to send.
///
///
/// Its size must be 125 bytes or less in UTF-8.
///
///
///
/// could not be UTF-8-encoded.
///
///
/// The size of is greater than 125 bytes.
///
///
/// The Ping method is not available when the session has not started yet.
///
protected bool Ping (string message)
{
if (_websocket == null) {
var msg = "The Ping method is not available.";
throw new InvalidOperationException (msg);
}
return _websocket.Ping (message);
}
///
/// Sends the specified data to the client for a session.
///
///
/// An array of that specifies the binary data to send.
///
///
/// is .
///
///
///
/// The Send method is not available when the session has not
/// started yet.
///
///
/// -or-
///
///
/// The Send method is not available when the current state of
/// the WebSocket interface is not Open.
///
///
protected void Send (byte[] data)
{
if (_websocket == null) {
var msg = "The Send method is not available.";
throw new InvalidOperationException (msg);
}
_websocket.Send (data);
}
///
/// Sends the specified file to the client for a session.
///
///
///
/// A that specifies the file to send.
///
///
/// The file is sent as the binary data.
///
///
///
///
/// The file does not exist.
///
///
/// -or-
///
///
/// The file could not be opened.
///
///
///
/// is .
///
///
///
/// The Send method is not available when the session has not
/// started yet.
///
///
/// -or-
///
///
/// The Send method is not available when the current state of
/// the WebSocket interface is not Open.
///
///
protected void Send (FileInfo fileInfo)
{
if (_websocket == null) {
var msg = "The Send method is not available.";
throw new InvalidOperationException (msg);
}
_websocket.Send (fileInfo);
}
///
/// Sends the specified data to the client for a session.
///
///
/// A that specifies the text data to send.
///
///
/// could not be UTF-8-encoded.
///
///
/// is .
///
///
///
/// The Send method is not available when the session has not
/// started yet.
///
///
/// -or-
///
///
/// The Send method is not available when the current state of
/// the WebSocket interface is not Open.
///
///
protected void Send (string data)
{
if (_websocket == null) {
var msg = "The Send method is not available.";
throw new InvalidOperationException (msg);
}
_websocket.Send (data);
}
///
/// Sends the data from the specified stream instance to the client for
/// a session.
///
///
///
/// A instance from which to read the data to send.
///
///
/// The data is sent as the binary data.
///
///
///
/// An that specifies the number of bytes to send.
///
///
///
/// cannot be read.
///
///
/// -or-
///
///
/// is less than 1.
///
///
/// -or-
///
///
/// No data could be read from .
///
///
///
/// is .
///
///
///
/// The Send method is not available when the session has not
/// started yet.
///
///
/// -or-
///
///
/// The Send method is not available when the current state of
/// the WebSocket interface is not Open.
///
///
protected void Send (Stream stream, int length)
{
if (_websocket == null) {
var msg = "The Send method is not available.";
throw new InvalidOperationException (msg);
}
_websocket.Send (stream, length);
}
///
/// Sends the specified data to the client for a session asynchronously.
///
///
/// This method does not wait for the send to be complete.
///
///
/// An array of that specifies the binary data to send.
///
///
///
/// An delegate.
///
///
/// It specifies the delegate called when the send is complete.
///
///
/// The parameter passed to the delegate is true
/// if the send has successfully done; otherwise, false.
///
///
/// if not necessary.
///
///
///
/// is .
///
///
///
/// The SendAsync method is not available when the session has not
/// started yet.
///
///
/// -or-
///
///
/// The SendAsync method is not available when the current state of
/// the WebSocket interface is not Open.
///
///
protected void SendAsync (byte[] data, Action completed)
{
if (_websocket == null) {
var msg = "The SendAsync method is not available.";
throw new InvalidOperationException (msg);
}
_websocket.SendAsync (data, completed);
}
///
/// Sends the specified file to the client for a session asynchronously.
///
///
/// This method does not wait for the send to be complete.
///
///
///
/// A that specifies the file to send.
///
///
/// The file is sent as the binary data.
///
///
///
///
/// An delegate.
///
///
/// It specifies the delegate called when the send is complete.
///
///
/// The parameter passed to the delegate is true
/// if the send has successfully done; otherwise, false.
///
///
/// if not necessary.
///
///
///
///
/// The file does not exist.
///
///
/// -or-
///
///
/// The file could not be opened.
///
///
///
/// is .
///
///
///
/// The SendAsync method is not available when the session has not
/// started yet.
///
///
/// -or-
///
///
/// The SendAsync method is not available when the current state of
/// the WebSocket interface is not Open.
///
///
protected void SendAsync (FileInfo fileInfo, Action completed)
{
if (_websocket == null) {
var msg = "The SendAsync method is not available.";
throw new InvalidOperationException (msg);
}
_websocket.SendAsync (fileInfo, completed);
}
///
/// Sends the specified data to the client for a session asynchronously.
///
///
/// This method does not wait for the send to be complete.
///
///
/// A that specifies the text data to send.
///
///
///
/// An delegate.
///
///
/// It specifies the delegate called when the send is complete.
///
///
/// The parameter passed to the delegate is true
/// if the send has successfully done; otherwise, false.
///
///
/// if not necessary.
///
///
///
/// could not be UTF-8-encoded.
///
///
/// is .
///
///
///
/// The SendAsync method is not available when the session has not
/// started yet.
///
///
/// -or-
///
///
/// The SendAsync method is not available when the current state of
/// the WebSocket interface is not Open.
///
///
protected void SendAsync (string data, Action completed)
{
if (_websocket == null) {
var msg = "The SendAsync method is not available.";
throw new InvalidOperationException (msg);
}
_websocket.SendAsync (data, completed);
}
///
/// Sends the data from the specified stream instance to the client for
/// a session asynchronously.
///
///
/// This method does not wait for the send to be complete.
///
///
///
/// A instance from which to read the data to send.
///
///
/// The data is sent as the binary data.
///
///
///
/// An that specifies the number of bytes to send.
///
///
///
/// An delegate.
///
///
/// It specifies the delegate called when the send is complete.
///
///
/// The parameter passed to the delegate is true
/// if the send has successfully done; otherwise, false.
///
///
/// if not necessary.
///
///
///
///
/// cannot be read.
///
///
/// -or-
///
///
/// is less than 1.
///
///
/// -or-
///
///
/// No data could be read from .
///
///
///
/// is .
///
///
///
/// The SendAsync method is not available when the session has not
/// started yet.
///
///
/// -or-
///
///
/// The SendAsync method is not available when the current state of
/// the WebSocket interface is not Open.
///
///
protected void SendAsync (Stream stream, int length, Action completed)
{
if (_websocket == null) {
var msg = "The SendAsync method is not available.";
throw new InvalidOperationException (msg);
}
_websocket.SendAsync (stream, length, completed);
}
#endregion
#region Explicit Interface Implementations
///
/// Gets the WebSocket interface for a session.
///
///
///
/// A that represents
/// the WebSocket interface.
///
///
/// when the session has not started yet.
///
///
WebSocket IWebSocketSession.WebSocket {
get {
return _websocket;
}
}
#endregion
}
}