C# Class WebSocketSharp.Server.WebSocketService

Provides the basic functions of the WebSocket service used by the WebSocket service host.
The WebSocketService class is an abstract class.
Inheritance: IWebSocketSession
显示文件 Open project: uken/websocket-sharp Class Usage Examples

Protected Methods

Method Description
Error ( string message ) : void

Calls the OnError method with the specified message.

OnClose ( CloseEventArgs e ) : void

Is called when the WebSocket connection has been closed.

OnError ( ErrorEventArgs e ) : void

Is called when the inner WebSocket or current WebSocketService gets an error.

OnMessage ( MessageEventArgs e ) : void

Is called when the inner WebSocket receives a data frame.

OnOpen ( ) : void

Is called when the WebSocket connection has been established.

Send ( FileInfo file ) : void

Sends the specified file as a binary data to the client on the current session in the WebSocket service.

Send ( byte data ) : void

Sends a binary data to the client on the current session in the WebSocket service.

Send ( string data ) : void

Sends a text data to the client on the current session in the WebSocket service.

SendAsync ( FileInfo file, Action completed ) : void

Sends the specified file as a binary data asynchronously to the client on the current session in the WebSocket service.

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

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

Sends a binary data from the specified Stream asynchronously to the client on the current session in the WebSocket service.

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

SendAsync ( byte data, Action completed ) : void

Sends a binary data asynchronously to the client on the current session in the WebSocket service.

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

SendAsync ( string data, Action completed ) : void

Sends a text data asynchronously to the client on the current session in the WebSocket service.

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

ValidateCookies ( WebSocketSharp.Net.CookieCollection request, WebSocketSharp.Net.CookieCollection response ) : bool

Validates the HTTP Cookies used in the WebSocket connection request.

This method is called when the inner WebSocket validates the WebSocket connection request.

WebSocketService ( ) : System

Initializes a new instance of the WebSocketService class.

Private Methods

Method Description
Start ( WebSocketContext context, WebSocketSessionManager sessions ) : void
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.
protected Error ( string message ) : void
message string /// A that represents the error message. ///
return void

OnClose() protected method

Is called when the WebSocket connection has been closed.
protected OnClose ( CloseEventArgs e ) : void
e CloseEventArgs /// A that contains the event data associated /// with an inner event. ///
return void

OnError() protected method

Is called when the inner WebSocket or current WebSocketService gets an error.
protected OnError ( ErrorEventArgs e ) : void
e ErrorEventArgs /// An that contains the event data associated /// with an inner event. ///
return void

OnMessage() protected method

Is called when the inner WebSocket receives a data frame.
protected OnMessage ( MessageEventArgs e ) : void
e MessageEventArgs /// A that contains the event data associated /// with an inner event. ///
return void

OnOpen() protected method

Is called when the WebSocket connection has been established.
protected OnOpen ( ) : void
return void

Send() protected method

Sends the specified file as a binary data to the client on the current session in the WebSocket service.
protected Send ( FileInfo file ) : void
file FileInfo /// A that represents the file to send. ///
return void

Send() protected method

Sends a binary data to the client on the current session in the WebSocket service.
protected Send ( byte data ) : void
data byte /// An array of that represents the binary data to send. ///
return void

Send() protected method

Sends a text data to the client on the current session in the WebSocket service.
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 a binary data asynchronously to the client on the current session in the WebSocket service.
This method doesn't wait for the send to be complete.
protected SendAsync ( FileInfo file, Action completed ) : void
file 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; otherwise, false. ///
return void

SendAsync() protected method

Sends a binary data from the specified Stream asynchronously to the client on the current session in the WebSocket service.
This method doesn't wait for the send to be complete.
protected SendAsync ( System.Stream stream, int length, Action completed ) : void
stream System.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; otherwise, false. ///
return void

SendAsync() protected method

Sends a binary data asynchronously to the client on the current session in the WebSocket service.
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; otherwise, false. ///
return void

SendAsync() protected method

Sends a text data asynchronously to the client on the current session in the WebSocket service.
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; otherwise, false. ///
return void

ValidateCookies() protected method

Validates the HTTP Cookies used in the WebSocket connection request.
This method is called when the inner WebSocket validates the WebSocket connection request.
protected ValidateCookies ( WebSocketSharp.Net.CookieCollection request, WebSocketSharp.Net.CookieCollection response ) : bool
request WebSocketSharp.Net.CookieCollection /// A that contains the collection of the /// cookies to validate. ///
response WebSocketSharp.Net.CookieCollection /// A that receives the cookies to send to the /// client. ///
return bool

WebSocketService() protected method

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