Skip to content

Commit 4375a5c

Browse files
committed
Modified README.md
1 parent df2726c commit 4375a5c

File tree

1 file changed

+59
-59
lines changed

1 file changed

+59
-59
lines changed

README.md

+59-59
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@
1111
using System;
1212
using WebSocketSharp;
1313

14-
namespace Example {
15-
16-
public class Program {
17-
18-
public static void Main(string[] args)
14+
namespace Example
15+
{
16+
public class Program
17+
{
18+
public static void Main (string [] args)
1919
{
20-
using (var ws = new WebSocket("ws://dragonsnest.far/Laputa"))
20+
using (var ws = new WebSocket ("ws://dragonsnest.far/Laputa"))
2121
{
2222
ws.OnMessage += (sender, e) =>
2323
{
24-
Console.WriteLine("Laputa says: {0}", e.Data);
24+
Console.WriteLine ("Laputa says: {0}", e.Data);
2525
};
2626

27-
ws.Connect();
28-
ws.Send("BALUS");
29-
Console.ReadKey(true);
27+
ws.Connect ();
28+
ws.Send ("BALUS");
29+
Console.ReadKey (true);
3030
}
3131
}
3232
}
@@ -48,7 +48,7 @@ The `WebSocket` class exists in the `WebSocketSharp` namespace.
4848
Creating a instance of the `WebSocket` class with the specified WebSocket URL to connect.
4949

5050
```cs
51-
using (var ws = new WebSocket("ws://example.com"))
51+
using (var ws = new WebSocket ("ws://example.com"))
5252
{
5353
...
5454
}
@@ -84,11 +84,11 @@ ws.OnMessage += (sender, e) =>
8484
};
8585
```
8686

87-
`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.
8888

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.
9090

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.
9292

9393
```cs
9494
if (e.Type == Opcode.TEXT)
@@ -114,7 +114,7 @@ ws.OnError += (sender, e) =>
114114
...
115115
};
116116
```
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.
118118

119119
##### WebSocket.OnClose Event #####
120120

@@ -127,41 +127,41 @@ ws.OnClose += (sender, e) =>
127127
};
128128
```
129129

130-
`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.
131131

132132
#### Step 4 ####
133133

134134
Connecting to the WebSocket server.
135135

136136
```cs
137-
ws.Connect();
137+
ws.Connect ();
138138
```
139139

140140
#### Step 5 ####
141141

142142
Sending a data.
143143

144144
```cs
145-
ws.Send(data);
145+
ws.Send (data);
146146
```
147147

148148
The `Send` method is overloaded.
149149

150-
The types of `data` are `string`, `byte[]` and `FileInfo` class.
150+
The types of `data` are `string`, `byte []` and `FileInfo` class.
151151

152152
#### Step 6 ####
153153

154154
Closing the WebSocket connection.
155155

156156
```cs
157-
ws.Close(code, reason);
157+
ws.Close (code, reason);
158158
```
159159

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.
161161

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`.
163163

164-
In addition, the `Close()` and `Close(code)` methods exist.
164+
In addition, the `Close ()` and `Close (code)` methods exist.
165165

166166
### WebSocket Server ###
167167

@@ -170,27 +170,27 @@ using System;
170170
using WebSocketSharp;
171171
using WebSocketSharp.Server;
172172

173-
namespace Example {
174-
173+
namespace Example
174+
{
175175
public class Laputa : WebSocketService
176176
{
177-
protected override void OnMessage(MessageEventArgs e)
177+
protected override void OnMessage (MessageEventArgs e)
178178
{
179-
var msg = e.Data.ToLower() == "balus"
179+
var msg = e.Data.ToLower () == "balus"
180180
? "I've been balused already..."
181181
: "I'm not available now.";
182-
Send(msg);
182+
Send (msg);
183183
}
184184
}
185185

186-
public class Program {
187-
188-
public static void Main(string[] args)
186+
public class Program
187+
{
188+
public static void Main (string [] args)
189189
{
190-
var wssv = new WebSocketServiceHost<Laputa>("ws://dragonsnest.far/Laputa");
191-
wssv.Start();
192-
Console.ReadKey(true);
193-
wssv.Stop();
190+
var wssv = new WebSocketServiceHost<Laputa> ("ws://dragonsnest.far/Laputa");
191+
wssv.Start ();
192+
Console.ReadKey (true);
193+
wssv.Stop ();
194194
}
195195
}
196196
}
@@ -210,7 +210,7 @@ The `WebSocketServer`, `WebSocketServiceHost<T>` and `WebSocketService` classes
210210

211211
Creating a class that inherits the `WebSocketService` class.
212212

213-
For example, if you want to provide the echo service,
213+
For example, if you want to provide an echo service,
214214

215215
```cs
216216
using System;
@@ -219,14 +219,14 @@ using WebSocketSharp.Server;
219219

220220
public class Echo : WebSocketService
221221
{
222-
protected override void OnMessage(MessageEventArgs e)
222+
protected override void OnMessage (MessageEventArgs e)
223223
{
224-
Send(e.Data);
224+
Send (e.Data);
225225
}
226226
}
227227
```
228228

229-
Or if you want to provide the chat service,
229+
Or if you want to provide a chat service,
230230

231231
```cs
232232
using System;
@@ -235,9 +235,9 @@ using WebSocketSharp.Server;
235235

236236
public class Chat : WebSocketService
237237
{
238-
protected override void OnMessage(MessageEventArgs e)
238+
protected override void OnMessage (MessageEventArgs e)
239239
{
240-
Broadcast(e.Data);
240+
Broadcast (e.Data);
241241
}
242242
}
243243
```
@@ -251,15 +251,15 @@ In addition, if you override the `OnOpen`, `OnError` and `OnClose` methods, each
251251
Creating a instance of the `WebSocketServiceHost<T>` class if you want the single WebSocket service server.
252252

253253
```cs
254-
var wssv = new WebSocketServiceHost<Echo>("ws://example.com:4649");
254+
var wssv = new WebSocketServiceHost<Echo> ("ws://example.com:4649");
255255
```
256256

257257
Or creating a instance of the `WebSocketServer` class if you want the multi WebSocket service server.
258258

259259
```cs
260-
var wssv = new WebSocketServer(4649);
261-
wssv.AddWebSocketService<Echo>("/Echo");
262-
wssv.AddWebSocketService<Chat>("/Chat");
260+
var wssv = new WebSocketServer (4649);
261+
wssv.AddWebSocketService<Echo> ("/Echo");
262+
wssv.AddWebSocketService<Chat> ("/Chat");
263263
```
264264

265265
You can add any WebSocket service with a specified path to the service to your `WebSocketServer` by using the `WebSocketServer.AddWebSocketService<T>` method.
@@ -285,7 +285,7 @@ wssv.OnError += (sender, e) =>
285285
};
286286
```
287287

288-
`e.Message` (`WebSocketSharp.ErrorEventArgs.Message`, the type of this property is `string`) contains an error message, so you use this.
288+
`e.Message` (`WebSocketSharp.ErrorEventArgs.Message`, its type is `string`) contains an error message, so you use it.
289289

290290
##### WebSocketServer.OnError Event #####
291291

@@ -296,15 +296,15 @@ Same as the `WebSocketServiceHost<T>.OnError` event.
296296
Starting the server.
297297

298298
```cs
299-
wssv.Start();
299+
wssv.Start ();
300300
```
301301

302302
#### Step 6 ####
303303

304304
Stopping the server.
305305

306306
```cs
307-
wssv.Stop();
307+
wssv.Stop ();
308308
```
309309

310310
### HTTP Server with the WebSocket ###
@@ -314,8 +314,8 @@ I modified the `System.Net.HttpListener`, `System.Net.HttpListenerContext` and s
314314
You can add any WebSocket service with a specified path to the service to your `HttpServer` by using the `HttpServer.AddWebSocketService<T>` method.
315315

316316
```cs
317-
var httpsv = new HttpServer(4649);
318-
httpsv.AddWebSocketService<Echo>("/");
317+
var httpsv = new HttpServer (4649);
318+
httpsv.AddWebSocketService<Echo> ("/");
319319
```
320320

321321
For more information, could you see **[Example3]**?
@@ -325,13 +325,13 @@ For more information, could you see **[Example3]**?
325325
As a **WebSocket Client**, creating a instance of the `WebSocket` class with the WebSocket URL with **wss** scheme.
326326

327327
```cs
328-
using (var ws = new WebSocket("wss://example.com"))
328+
using (var ws = new WebSocket ("wss://example.com"))
329329
{
330330
...
331331
}
332332
```
333333

334-
If you want to set the custom validation for the server certificate, you can use the `WebSocket.ServerCertificateValidationCallback` property.
334+
If you want to set the custom validation for the server certificate, you use the `WebSocket.ServerCertificateValidationCallback` property.
335335

336336
```cs
337337
ws.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) =>
@@ -346,8 +346,8 @@ If you set this property to nothing, the validation does nothing with the server
346346
As a **WebSocket Server**, creating and setting a instance of the WebSocket server with some settings for the secure connection.
347347

348348
```cs
349-
var wssv = new WebSocketServer(4649, true);
350-
wssv.Certificate = new X509Certificate2("/path/to/cert.pfx", "password for cert.pfx");
349+
var wssv = new WebSocketServer (4649, true);
350+
wssv.Certificate = new X509Certificate2 ("/path/to/cert.pfx", "password for cert.pfx");
351351
```
352352

353353
### Logging ###
@@ -356,25 +356,25 @@ The `WebSocket` class includes own logging functions.
356356

357357
The `WebSocket.Log` property provides the logging functions.
358358

359-
If you want to change the current logging level (the default is `LogLevel.ERROR`), you can use the `WebSocket.Log.Level` property.
359+
If you want to change the current logging level (the default is `LogLevel.ERROR`), you use the `WebSocket.Log.Level` property.
360360

361361
```cs
362362
ws.Log.Level = LogLevel.DEBUG;
363363
```
364364

365-
This setting means that the logging outputs with a less than `LogLevel.DEBUG` are not outputted.
365+
The above means that the logging outputs with a less than `LogLevel.DEBUG` are not outputted.
366366

367-
And if you want to output a log, you can use some output methods. The following outputs a log with `LogLevel.DEBUG`.
367+
And if you want to output a log, you use some output methods. The following outputs a log with `LogLevel.DEBUG`.
368368

369369
```cs
370-
ws.Log.Debug("This is a debug message.");
370+
ws.Log.Debug ("This is a debug message.");
371371
```
372372

373373
The `WebSocketServiceHost<T>`, `WebSocketServer` and `HttpServer` classes include the same logging functions.
374374

375375
## Examples ##
376376

377-
Examples of using **websocket-sharp**.
377+
Examples using **websocket-sharp**.
378378

379379
### Example ###
380380

0 commit comments

Comments
 (0)