Fix a few for README.md
This commit is contained in:
parent
c5c39cf415
commit
57767e3d78
21
README.md
21
README.md
@ -179,7 +179,7 @@ ws.OnClose += (sender, e) => {
|
|||||||
|
|
||||||
`e` has passed as a `WebSocketSharp.CloseEventArgs`.
|
`e` has passed as a `WebSocketSharp.CloseEventArgs`.
|
||||||
|
|
||||||
`e.Code` property returns a `ushort` that represents the status code indicating the reason for closure, and `e.Reason` property returns a `string` that represents the reason for closure. So you should use them to get the reason for closure.
|
`e.Code` property returns a `ushort` that represents the status code indicating the reason for the close, and `e.Reason` property returns a `string` that represents the reason for the close. So you should use them to get the reason for the close.
|
||||||
|
|
||||||
#### Step 4 ####
|
#### Step 4 ####
|
||||||
|
|
||||||
@ -338,7 +338,7 @@ Creating an instance of the `WebSocketServer` class.
|
|||||||
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");
|
||||||
wssv.AddWebSocketService<Chat> ("/ChatWithNiceBoat", () => new Chat (" Nice boat."));
|
wssv.AddWebSocketService<Chat> ("/ChatWithNyan", () => new Chat (" Nyan."));
|
||||||
```
|
```
|
||||||
|
|
||||||
You can add any WebSocket service to your `WebSocketServer` with the specified path to the service, using the `WebSocketServer.AddWebSocketService<TWithNew> (string)` or `WebSocketServer.AddWebSocketService<T> (string, Func<T>)` method.
|
You can add any WebSocket service to your `WebSocketServer` with the specified path to the service, using the `WebSocketServer.AddWebSocketService<TWithNew> (string)` or `WebSocketServer.AddWebSocketService<T> (string, Func<T>)` method.
|
||||||
@ -385,7 +385,7 @@ You can add any WebSocket service to your `HttpServer` with the specified path t
|
|||||||
var httpsv = new HttpServer (4649);
|
var httpsv = new HttpServer (4649);
|
||||||
httpsv.AddWebSocketService<Echo> ("/Echo");
|
httpsv.AddWebSocketService<Echo> ("/Echo");
|
||||||
httpsv.AddWebSocketService<Chat> ("/Chat");
|
httpsv.AddWebSocketService<Chat> ("/Chat");
|
||||||
httpsv.AddWebSocketService<Chat> ("/ChatWithNiceBoat", () => new Chat (" Nice boat."));
|
httpsv.AddWebSocketService<Chat> ("/ChatWithNyan", () => new Chat (" Nyan."));
|
||||||
```
|
```
|
||||||
|
|
||||||
For more information, could you see **[Example3]**?
|
For more information, could you see **[Example3]**?
|
||||||
@ -457,9 +457,9 @@ As a **WebSocket Server**, you should set an HTTP authentication scheme, a realm
|
|||||||
```cs
|
```cs
|
||||||
wssv.AuthenticationSchemes = AuthenticationSchemes.Basic;
|
wssv.AuthenticationSchemes = AuthenticationSchemes.Basic;
|
||||||
wssv.Realm = "WebSocket Test";
|
wssv.Realm = "WebSocket Test";
|
||||||
wssv.UserCredentialsFinder = identity => {
|
wssv.UserCredentialsFinder = id => {
|
||||||
var expected = "nobita";
|
var expected = "nobita";
|
||||||
return identity.Name == expected
|
return id.Name == expected
|
||||||
? new NetworkCredential (expected, "password", "gunfighter") // User name, password, and roles
|
? new NetworkCredential (expected, "password", "gunfighter") // User name, password, and roles
|
||||||
: null; // If the user credentials not found.
|
: null; // If the user credentials not found.
|
||||||
};
|
};
|
||||||
@ -499,7 +499,6 @@ As a **WebSocket Server**, if you would like to get the **Query String** include
|
|||||||
public class Chat : WebSocketService
|
public class Chat : WebSocketService
|
||||||
{
|
{
|
||||||
private string _name;
|
private string _name;
|
||||||
|
|
||||||
...
|
...
|
||||||
|
|
||||||
protected override void OnOpen ()
|
protected override void OnOpen ()
|
||||||
@ -517,11 +516,11 @@ And if you would like to check the **Origin header and Cookies** included in eac
|
|||||||
wssv.AddWebSocketService<Chat> (
|
wssv.AddWebSocketService<Chat> (
|
||||||
"/Chat",
|
"/Chat",
|
||||||
() => new Chat () {
|
() => new Chat () {
|
||||||
OriginValidator = value => {
|
OriginValidator = val => {
|
||||||
// Check 'value' of the Origin header, and return true if valid
|
// Check value of the Origin header, and return true if valid
|
||||||
Uri origin;
|
Uri origin;
|
||||||
return !value.IsNullOrEmpty () &&
|
return !val.IsNullOrEmpty () &&
|
||||||
Uri.TryCreate (value, UriKind.Absolute, out origin) &&
|
Uri.TryCreate (val, UriKind.Absolute, out origin) &&
|
||||||
origin.Host == "example.com";
|
origin.Host == "example.com";
|
||||||
},
|
},
|
||||||
CookiesValidator = (req, res) => {
|
CookiesValidator = (req, res) => {
|
||||||
@ -582,7 +581,7 @@ And Example1 uses **[Json.NET]**.
|
|||||||
|
|
||||||
**[Example3]** starts an HTTP server that allows to accept the WebSocket connection requests.
|
**[Example3]** starts an HTTP server that allows to accept the WebSocket connection requests.
|
||||||
|
|
||||||
Could you access to [http://localhost:4649](http://localhost:4649) to do **WebSocket Echo Test** with your web browser after Example3 running?
|
Would you access to [http://localhost:4649](http://localhost:4649) to do **WebSocket Echo Test** with your web browser after Example3 running?
|
||||||
|
|
||||||
## Supported WebSocket Specifications ##
|
## Supported WebSocket Specifications ##
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user