Modified README.md
This commit is contained in:
parent
df2726ce9d
commit
4375a5c2a3
46
README.md
46
README.md
@ -11,10 +11,10 @@
|
||||
using System;
|
||||
using WebSocketSharp;
|
||||
|
||||
namespace Example {
|
||||
|
||||
public class Program {
|
||||
|
||||
namespace Example
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main (string [] args)
|
||||
{
|
||||
using (var ws = new WebSocket ("ws://dragonsnest.far/Laputa"))
|
||||
@ -84,11 +84,11 @@ ws.OnMessage += (sender, e) =>
|
||||
};
|
||||
```
|
||||
|
||||
`e.Type` (`WebSocketSharp.MessageEventArgs.Type`, the type of this property is `WebSocketSharp.Opcode`) indicates the **Frame Type** of a WebSocket frame, so by checking this property, you determine which item you should use.
|
||||
`e.Type` (`WebSocketSharp.MessageEventArgs.Type`, its type is `WebSocketSharp.Opcode`) indicates the **Frame Type** of a received WebSocket frame. So by checking it, you determine which item you should use.
|
||||
|
||||
If `e.Type` equals `Opcode.TEXT`, you use `e.Data` (`WebSocketSharp.MessageEventArgs.Data`, the type of this property is `string`) that contains the received **Text** data.
|
||||
If `e.Type` equals `Opcode.TEXT`, you use `e.Data` (`WebSocketSharp.MessageEventArgs.Data`, its type is `string`) that contains a received **Text** data.
|
||||
|
||||
If `e.Type` equals `Opcode.BINARY`, you use `e.RawData` (`WebSocketSharp.MessageEventArgs.RawData`, the type of this property is `byte[]`) that contains the received **Binary** data.
|
||||
If `e.Type` equals `Opcode.BINARY`, you use `e.RawData` (`WebSocketSharp.MessageEventArgs.RawData`, its type is `byte []`) that contains a received **Binary** data.
|
||||
|
||||
```cs
|
||||
if (e.Type == Opcode.TEXT)
|
||||
@ -114,7 +114,7 @@ ws.OnError += (sender, e) =>
|
||||
...
|
||||
};
|
||||
```
|
||||
`e.Message` (`WebSocketSharp.ErrorEventArgs.Message`, the type of this property is `string`) contains an error message, so you use this.
|
||||
`e.Message` (`WebSocketSharp.ErrorEventArgs.Message`, its type is `string`) contains an error message, so you use it.
|
||||
|
||||
##### WebSocket.OnClose Event #####
|
||||
|
||||
@ -127,7 +127,7 @@ ws.OnClose += (sender, e) =>
|
||||
};
|
||||
```
|
||||
|
||||
`e.Code` (`WebSocketSharp.CloseEventArgs.Code`, the type of this property is `ushort`) contains a status code indicating the reason for closure and `e.Reason` (`WebSocketSharp.CloseEventArgs.Reason`, the type of this property is `string`) contains the reason for closure, so you use these.
|
||||
`e.Code` (`WebSocketSharp.CloseEventArgs.Code`, its type is `ushort`) contains a status code indicating the reason for closure and `e.Reason` (`WebSocketSharp.CloseEventArgs.Reason`, its type is `string`) contains the reason for closure, so you use them.
|
||||
|
||||
#### Step 4 ####
|
||||
|
||||
@ -157,9 +157,9 @@ Closing the WebSocket connection.
|
||||
ws.Close (code, reason);
|
||||
```
|
||||
|
||||
If you want to close the WebSocket connection explicitly, you can use the `Close` method.
|
||||
If you want to close the WebSocket connection explicitly, you use the `Close` method.
|
||||
|
||||
And the `Close` method is overloaded. The types of `code` are `WebSocketSharp.CloseStatusCode` and `ushort`, the type of `reason` is `string`.
|
||||
The `Close` method is overloaded. The types of `code` are `WebSocketSharp.CloseStatusCode` and `ushort`, the type of `reason` is `string`.
|
||||
|
||||
In addition, the `Close ()` and `Close (code)` methods exist.
|
||||
|
||||
@ -170,8 +170,8 @@ using System;
|
||||
using WebSocketSharp;
|
||||
using WebSocketSharp.Server;
|
||||
|
||||
namespace Example {
|
||||
|
||||
namespace Example
|
||||
{
|
||||
public class Laputa : WebSocketService
|
||||
{
|
||||
protected override void OnMessage (MessageEventArgs e)
|
||||
@ -183,8 +183,8 @@ namespace Example {
|
||||
}
|
||||
}
|
||||
|
||||
public class Program {
|
||||
|
||||
public class Program
|
||||
{
|
||||
public static void Main (string [] args)
|
||||
{
|
||||
var wssv = new WebSocketServiceHost<Laputa> ("ws://dragonsnest.far/Laputa");
|
||||
@ -210,7 +210,7 @@ The `WebSocketServer`, `WebSocketServiceHost<T>` and `WebSocketService` classes
|
||||
|
||||
Creating a class that inherits the `WebSocketService` class.
|
||||
|
||||
For example, if you want to provide the echo service,
|
||||
For example, if you want to provide an echo service,
|
||||
|
||||
```cs
|
||||
using System;
|
||||
@ -226,7 +226,7 @@ public class Echo : WebSocketService
|
||||
}
|
||||
```
|
||||
|
||||
Or if you want to provide the chat service,
|
||||
Or if you want to provide a chat service,
|
||||
|
||||
```cs
|
||||
using System;
|
||||
@ -285,7 +285,7 @@ wssv.OnError += (sender, e) =>
|
||||
};
|
||||
```
|
||||
|
||||
`e.Message` (`WebSocketSharp.ErrorEventArgs.Message`, the type of this property is `string`) contains an error message, so you use this.
|
||||
`e.Message` (`WebSocketSharp.ErrorEventArgs.Message`, its type is `string`) contains an error message, so you use it.
|
||||
|
||||
##### WebSocketServer.OnError Event #####
|
||||
|
||||
@ -331,7 +331,7 @@ using (var ws = new WebSocket("wss://example.com"))
|
||||
}
|
||||
```
|
||||
|
||||
If you want to set the custom validation for the server certificate, you can use the `WebSocket.ServerCertificateValidationCallback` property.
|
||||
If you want to set the custom validation for the server certificate, you use the `WebSocket.ServerCertificateValidationCallback` property.
|
||||
|
||||
```cs
|
||||
ws.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) =>
|
||||
@ -356,15 +356,15 @@ The `WebSocket` class includes own logging functions.
|
||||
|
||||
The `WebSocket.Log` property provides the logging functions.
|
||||
|
||||
If you want to change the current logging level (the default is `LogLevel.ERROR`), you can use the `WebSocket.Log.Level` property.
|
||||
If you want to change the current logging level (the default is `LogLevel.ERROR`), you use the `WebSocket.Log.Level` property.
|
||||
|
||||
```cs
|
||||
ws.Log.Level = LogLevel.DEBUG;
|
||||
```
|
||||
|
||||
This setting means that the logging outputs with a less than `LogLevel.DEBUG` are not outputted.
|
||||
The above means that the logging outputs with a less than `LogLevel.DEBUG` are not outputted.
|
||||
|
||||
And if you want to output a log, you can use some output methods. The following outputs a log with `LogLevel.DEBUG`.
|
||||
And if you want to output a log, you use some output methods. The following outputs a log with `LogLevel.DEBUG`.
|
||||
|
||||
```cs
|
||||
ws.Log.Debug ("This is a debug message.");
|
||||
@ -374,7 +374,7 @@ The `WebSocketServiceHost<T>`, `WebSocketServer` and `HttpServer` classes includ
|
||||
|
||||
## Examples ##
|
||||
|
||||
Examples of using **websocket-sharp**.
|
||||
Examples using **websocket-sharp**.
|
||||
|
||||
### Example ###
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user