Modified some part (Step 4, 5 and 6) of WebSocket Client

This commit is contained in:
sta 2014-01-17 20:42:43 +09:00
parent 134d79a7f3
commit 97999b8492

View File

@ -174,9 +174,11 @@ Connecting to the WebSocket server.
ws.Connect ();
```
If you want to connect to the WebSocket server asynchronously, you should use the `WebSocket.ConnectAsync ()` method.
#### Step 5 ####
Sending a data.
Sending a data to the WebSocket server.
```cs
ws.Send (data);
@ -186,11 +188,9 @@ The `WebSocket.Send` method is overloaded.
The types of `data` are `string`, `byte []` and `System.IO.FileInfo`.
In addition, the `WebSocket.Send (stream, length)` method exists, too.
If you want to send a data to the WebSocket server asynchronously, you should use the `WebSocket.SendAsync (data, completed)` method.
These methods don't wait for the send to be complete. It means these methods behave asynchronously.
If you do something when the send is complete, you use any of some `WebSocket.Send (data, completed)` methods.
If you want to do something when the send is complete, you should set any action to `completed` (its type is `Action<bool>`).
#### Step 6 ####
@ -200,7 +200,7 @@ Closing the WebSocket connection.
ws.Close (code, reason);
```
If you explicitly close the WebSocket connection, you use the `WebSocket.Close` method.
If you want to close the WebSocket connection explicitly, you should use the `WebSocket.Close` method.
The `WebSocket.Close` method is overloaded.
@ -208,6 +208,8 @@ The types of `code` are `WebSocketSharp.CloseStatusCode` and `ushort`, and the t
In addition, the `WebSocket.Close ()` and `WebSocket.Close (code)` methods exist, too.
If you want to close the WebSocket connection asynchronously, you should use any of the `WebSocket.CloseAsync` methods.
### WebSocket Server ###
```cs