You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`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.
87
+
`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.
88
88
89
-
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.
89
+
If `e.Type` equals `Opcode.TEXT`, you use `e.Data` (`WebSocketSharp.MessageEventArgs.Data`, its type is `string`) that contains a received **Text** data.
90
90
91
-
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.
91
+
If `e.Type` equals `Opcode.BINARY`, you use `e.RawData` (`WebSocketSharp.MessageEventArgs.RawData`, its type is `byte[]`) that contains a received **Binary** data.
92
92
93
93
```cs
94
94
if (e.Type==Opcode.TEXT)
@@ -114,7 +114,7 @@ ws.OnError += (sender, e) =>
114
114
...
115
115
};
116
116
```
117
-
`e.Message` (`WebSocketSharp.ErrorEventArgs.Message`, the type of this property is `string`) contains an error message, so you use this.
117
+
`e.Message` (`WebSocketSharp.ErrorEventArgs.Message`, its type is `string`) contains an error message, so you use it.
`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.
130
+
`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.
131
131
132
132
#### Step 4 ####
133
133
134
134
Connecting to the WebSocket server.
135
135
136
136
```cs
137
-
ws.Connect();
137
+
ws.Connect();
138
138
```
139
139
140
140
#### Step 5 ####
141
141
142
142
Sending a data.
143
143
144
144
```cs
145
-
ws.Send(data);
145
+
ws.Send(data);
146
146
```
147
147
148
148
The `Send` method is overloaded.
149
149
150
-
The types of `data` are `string`, `byte[]` and `FileInfo` class.
150
+
The types of `data` are `string`, `byte[]` and `FileInfo` class.
151
151
152
152
#### Step 6 ####
153
153
154
154
Closing the WebSocket connection.
155
155
156
156
```cs
157
-
ws.Close(code, reason);
157
+
ws.Close(code, reason);
158
158
```
159
159
160
-
If you want to close the WebSocket connection explicitly, you can use the `Close` method.
160
+
If you want to close the WebSocket connection explicitly, you use the `Close` method.
161
161
162
-
And the`Close` method is overloaded. The types of `code` are `WebSocketSharp.CloseStatusCode` and `ushort`, the type of `reason` is `string`.
162
+
The`Close` method is overloaded. The types of `code` are `WebSocketSharp.CloseStatusCode` and `ushort`, the type of `reason` is `string`.
163
163
164
-
In addition, the `Close()` and `Close(code)` methods exist.
164
+
In addition, the `Close()` and `Close(code)` methods exist.
Or creating a instance of the `WebSocketServer` class if you want the multi WebSocket service server.
258
258
259
259
```cs
260
-
varwssv=newWebSocketServer(4649);
261
-
wssv.AddWebSocketService<Echo>("/Echo");
262
-
wssv.AddWebSocketService<Chat>("/Chat");
260
+
varwssv=newWebSocketServer(4649);
261
+
wssv.AddWebSocketService<Echo>("/Echo");
262
+
wssv.AddWebSocketService<Chat>("/Chat");
263
263
```
264
264
265
265
You can add any WebSocket service with a specified path to the service to your `WebSocketServer` by using the `WebSocketServer.AddWebSocketService<T>` method.
0 commit comments