C# Class WebSocketSharp.Server.WebSocketBehavior

Exposes the methods and properties used to define the behavior of a WebSocket service provided by the WebSocketServer or HttpServer.
The WebSocketBehavior class is an abstract class.
Inheritance: IWebSocketSession
Mostrar archivo Open project: sta/websocket-sharp Class Usage Examples

Protected Methods

Method Description
Error ( string message, Exception exception ) : void

Calls the OnError method with the specified message and exception.

This method doesn't call the OnError method if message is or empty.

OnClose ( CloseEventArgs e ) : void

Called when the WebSocket connection used in a session has been closed.

OnError ( ErrorEventArgs e ) : void

Called when the WebSocket used in a session gets an error.

OnMessage ( MessageEventArgs e ) : void

Called when the WebSocket used in a session receives a message.

OnOpen ( ) : void

Called when the WebSocket connection used in a session has been established.

Send ( FileInfo file ) : void

Sends the specified file as binary data to the client on a session.

This method is available after the WebSocket connection has been established.

Send ( byte data ) : void

Sends binary data to the client on a session.

This method is available after the WebSocket connection has been established.

Send ( string data ) : void

Sends text data to the client on a session.

This method is available after the WebSocket connection has been established.

SendAsync ( FileInfo file, Action completed ) : void

Sends the specified file as binary data asynchronously to the client on a session.

This method is available after the WebSocket connection has been established.

This method doesn't wait for the send to be complete.

SendAsync ( Stream stream, int length, Action completed ) : void

Sends binary data from the specified Stream asynchronously to the client on a session.

This method is available after the WebSocket connection has been established.

This method doesn't wait for the send to be complete.

SendAsync ( byte data, Action completed ) : void

Sends binary data asynchronously to the client on a session.

This method is available after the WebSocket connection has been established.

This method doesn't wait for the send to be complete.

SendAsync ( string data, Action completed ) : void

Sends text data asynchronously to the client on a session.

This method is available after the WebSocket connection has been established.

This method doesn't wait for the send to be complete.

WebSocketBehavior ( ) : System

Initializes a new instance of the WebSocketBehavior class.

Private Methods

Method Description
Start ( WebSocketContext context, WebSocketSessionManager sessions ) : void
checkHandshakeRequest ( WebSocketContext context ) : string
onClose ( object sender, CloseEventArgs e ) : void
onError ( object sender, ErrorEventArgs e ) : void
onMessage ( object sender, MessageEventArgs e ) : void
onOpen ( object sender, EventArgs e ) : void

Method Details

Error() protected method

Calls the OnError method with the specified message and exception.
This method doesn't call the OnError method if message is or empty.
protected Error ( string message, Exception exception ) : void
message string /// A that represents the error message. ///
exception System.Exception /// An instance that represents the cause of the error if any. ///
return void

OnClose() protected method

Called when the WebSocket connection used in a session has been closed.
protected OnClose ( CloseEventArgs e ) : void
e CloseEventArgs /// A that represents the event data passed to /// a event. ///
return void

OnError() protected method

Called when the WebSocket used in a session gets an error.
protected OnError ( ErrorEventArgs e ) : void
e System.IO.ErrorEventArgs /// A that represents the event data passed to /// a event. ///
return void

OnMessage() protected method

Called when the WebSocket used in a session receives a message.
protected OnMessage ( MessageEventArgs e ) : void
e MessageEventArgs /// A that represents the event data passed to /// a event. ///
return void

OnOpen() protected method

Called when the WebSocket connection used in a session has been established.
protected OnOpen ( ) : void
return void

Send() protected method

Sends the specified file as binary data to the client on a session.
This method is available after the WebSocket connection has been established.
protected Send ( FileInfo file ) : void
file System.IO.FileInfo /// A that represents the file to send. ///
return void

Send() protected method

Sends binary data to the client on a session.
This method is available after the WebSocket connection has been established.
protected Send ( byte data ) : void
data byte /// An array of that represents the binary data to send. ///
return void

Send() protected method

Sends text data to the client on a session.
This method is available after the WebSocket connection has been established.
protected Send ( string data ) : void
data string /// A that represents the text data to send. ///
return void

SendAsync() protected method

Sends the specified file as binary data asynchronously to the client on a session.

This method is available after the WebSocket connection has been established.

This method doesn't wait for the send to be complete.

protected SendAsync ( FileInfo file, Action completed ) : void
file System.IO.FileInfo /// A that represents the file to send. ///
completed Action /// An Action<bool> delegate that references the method(s) called when /// the send is complete. A passed to this delegate is true /// if the send is complete successfully. ///
return void

SendAsync() protected method

Sends binary data from the specified Stream asynchronously to the client on a session.

This method is available after the WebSocket connection has been established.

This method doesn't wait for the send to be complete.

protected SendAsync ( Stream stream, int length, Action completed ) : void
stream Stream /// A from which contains the binary data to send. ///
length int /// An that represents the number of bytes to send. ///
completed Action /// An Action<bool> delegate that references the method(s) called when /// the send is complete. A passed to this delegate is true /// if the send is complete successfully. ///
return void

SendAsync() protected method

Sends binary data asynchronously to the client on a session.

This method is available after the WebSocket connection has been established.

This method doesn't wait for the send to be complete.

protected SendAsync ( byte data, Action completed ) : void
data byte /// An array of that represents the binary data to send. ///
completed Action /// An Action<bool> delegate that references the method(s) called when /// the send is complete. A passed to this delegate is true /// if the send is complete successfully. ///
return void

SendAsync() protected method

Sends text data asynchronously to the client on a session.

This method is available after the WebSocket connection has been established.

This method doesn't wait for the send to be complete.

protected SendAsync ( string data, Action completed ) : void
data string /// A that represents the text data to send. ///
completed Action /// An Action<bool> delegate that references the method(s) called when /// the send is complete. A passed to this delegate is true /// if the send is complete successfully. ///
return void

WebSocketBehavior() protected method

Initializes a new instance of the WebSocketBehavior class.
protected WebSocketBehavior ( ) : System
return System