Modified some part (Step 3, 4 and 5) of 'WebSocket Server'
This commit is contained in:
parent
b5d9fea133
commit
fe08da93e9
18
README.md
18
README.md
@ -331,21 +331,21 @@ wssv.AddWebSocketService<Chat> ("/Chat");
|
|||||||
wssv.AddWebSocketService<Chat> ("/ChatWithNiceBoat", () => new Chat (" Nice boat."));
|
wssv.AddWebSocketService<Chat> ("/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<TWithNew>` or `WebSocketServer.AddWebSocketService<T>` method.
|
You can add any WebSocket service with the specified path to the service to your `WebSocketServer` 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 `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
|
$ sudo mono example2.exe
|
||||||
|
|
||||||
#### Step 4 ####
|
#### Step 4 ####
|
||||||
|
|
||||||
Starting the server.
|
Starting the WebSocket server.
|
||||||
|
|
||||||
```cs
|
```cs
|
||||||
wssv.Start ();
|
wssv.Start ();
|
||||||
@ -353,12 +353,18 @@ wssv.Start ();
|
|||||||
|
|
||||||
#### Step 5 ####
|
#### Step 5 ####
|
||||||
|
|
||||||
Stopping the server.
|
Stopping the WebSocket server.
|
||||||
|
|
||||||
```cs
|
```cs
|
||||||
wssv.Stop ();
|
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 ###
|
### 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.
|
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.
|
||||||
|
Loading…
Reference in New Issue
Block a user