From fe08da93e9c3f3ed3e922c5cabe4a14f72a75e8e Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 21 Jan 2014 03:04:13 +0900 Subject: [PATCH] Modified some part (Step 3, 4 and 5) of 'WebSocket Server' --- README.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 55f48544..8477093d 100644 --- a/README.md +++ b/README.md @@ -331,21 +331,21 @@ wssv.AddWebSocketService ("/Chat"); wssv.AddWebSocketService ("/ChatWithNiceBoat", () => new Chat (" Nice boat.")); ``` -You can add any WebSocket service with the specified path to the service to your `WebSocketServer` by using the `WebSocketServer.AddWebSocketService` or `WebSocketServer.AddWebSocketService` method. +You can add any WebSocket service with the specified path to the service to your `WebSocketServer` using the `WebSocketServer.AddWebSocketService` or `WebSocketServer.AddWebSocketService` method. The type of `TWithNew` must inherit the `WebSocketService` class and must have a public parameterless constructor. -The type of `T` must inherit `WebSocketService` class. +The type of `T` must inherit the `WebSocketService` class. -So you can use the classes created in **Step 2**. +So you can use the classes created in **Step 2** to add the WebSocket service. -If you create an instance of the `WebSocketServer` class without the port number, the `WebSocketServer` set the port number to **80** automatically. So it's necessary to run with root permission. +If you create an instance of the `WebSocketServer` class without a port number, the `WebSocketServer` set the port number to **80** automatically. So it's necessary to run with root permission. $ sudo mono example2.exe #### Step 4 #### -Starting the server. +Starting the WebSocket server. ```cs wssv.Start (); @@ -353,12 +353,18 @@ wssv.Start (); #### Step 5 #### -Stopping the server. +Stopping the WebSocket server. ```cs wssv.Stop (); ``` +The `WebSocketServer.Stop` method is overloaded. + +The `WebSocketServer.Stop ()` and `WebSocketServer.Stop (code, reason)` methods exist. + +The type of `code` is `ushort` or `WebSocketSharp.CloseStatusCode`, and the type of `reason` is `string`. + ### HTTP Server with the WebSocket ### I modified the `System.Net.HttpListener`, `System.Net.HttpListenerContext` and some other classes of [Mono] to create the HTTP server that can upgrade the connection to the WebSocket connection when it receives a WebSocket connection request.