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 (); ws.Connect ();
``` ```
If you want to connect to the WebSocket server asynchronously, you should use the `WebSocket.ConnectAsync ()` method.
#### Step 5 #### #### Step 5 ####
Sending a data. Sending a data to the WebSocket server.
```cs ```cs
ws.Send (data); ws.Send (data);
@ -186,11 +188,9 @@ The `WebSocket.Send` method is overloaded.
The types of `data` are `string`, `byte []` and `System.IO.FileInfo`. 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 want to do something when the send is complete, you should set any action to `completed` (its type is `Action<bool>`).
If you do something when the send is complete, you use any of some `WebSocket.Send (data, completed)` methods.
#### Step 6 #### #### Step 6 ####
@ -200,7 +200,7 @@ Closing the WebSocket connection.
ws.Close (code, reason); 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. 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. 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 ### ### WebSocket Server ###
```cs ```cs