@ -248,25 +261,23 @@ In addition, if you override the `OnOpen`, `OnError` and `OnClose` methods, each
#### Step 3 ####
#### Step 3 ####
Creating a instance of the `WebSocketServiceHost<T>` class if you want the single WebSocket service server.
Creating an instance of the `WebSocketServer` class.
```cs
var wssv = new WebSocketServiceHost<Echo> ("ws://example.com:4649");
```
Or creating a instance of the `WebSocketServer` class if you want the multi WebSocket service server.
```cs
```cs
var wssv = new WebSocketServer (4649);
var wssv = new WebSocketServer (4649);
wssv.AddWebSocketService<Echo> ("/Echo");
wssv.AddWebSocketService<Echo> ("/Echo");
wssv.AddWebSocketService<Chat> ("/Chat");
wssv.AddWebSocketService<Chat> ("/Chat", () => new Chat (" Nice boat."));
```
```
You can add any WebSocket service with a specified path to the service to your `WebSocketServer` by using the `WebSocketServer.AddWebSocketService<T>` method.
You can add any WebSocket service with a specified path to the service to your `WebSocketServer` by using the `WebSocketServer.AddWebSocketService<TWithNew>` or `WebSocketServer.AddWebSocketService<T>` 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` inherits `WebSocketService` class, so you can use a class that was created in **Step 2**.
So you can use the classes created in **Step 2**.
If you create a instance of the `WebSocketServer` class without the port number, the `WebSocketServer` set the port number to **80** automatically. So it is necessary to run with root permission.
If you create an instance of the `WebSocketServer` class without the port number, the `WebSocketServer` set the port number to **80** automatically. So it is necessary to run with root permission.
$ sudo mono example2.exe
$ sudo mono example2.exe
@ -290,18 +301,19 @@ wssv.Stop ();
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 receives a WebSocket connection request.
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 receives a WebSocket connection request.
You can add any WebSocket service with a specified path to the service to your `HttpServer` by using the `HttpServer.AddWebSocketService<T>` method.
You can add any WebSocket service with a specified path to the service to your `HttpServer` by using the `HttpServer.AddWebSocketService<TWithNew>` or `HttpServer.AddWebSocketService<T>` method.
```cs
```cs
var httpsv = new HttpServer (4649);
var httpsv = new HttpServer (4649);
httpsv.AddWebSocketService<Echo> ("/");
httpsv.AddWebSocketService<Echo> ("/Echo");
httpsv.AddWebSocketService<Chat> ("/Chat", () => new Chat (" Nice boat."));
```
```
For more information, could you see **[Example3]**?
For more information, could you see **[Example3]**?
### Secure Connection ###
### Secure Connection ###
As a **WebSocket Client**, creating a instance of the `WebSocket` class with the WebSocket URL with **wss** scheme.
As a **WebSocket Client**, creating an instance of the `WebSocket` class with the WebSocket URL with **wss** scheme.
```cs
```cs
using (var ws = new WebSocket ("wss://example.com"))
using (var ws = new WebSocket ("wss://example.com"))