Skip to content

Commit bfe0212

Browse files
LunarWatcherbsergean
authored andcommitted
Meta: documentation fixes (machinezone#127)
* Clarify versions, minor punctuation fix * Copyediting, borked URL * Fix Python comments in C++ code * Copyediting * Pretty code * Copyediting, pretty code * Typo * Pretty code
1 parent af1a54f commit bfe0212

File tree

7 files changed

+36
-36
lines changed

7 files changed

+36
-36
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
## Hello world
22

3-
![Alt text](https://travis-ci.org/machinezone/IXWebSocket.svg?branch=master)
3+
![Build status badge](https://travis-ci.org/machinezone/IXWebSocket.svg?branch=master)
44

55
IXWebSocket is a C++ library for WebSocket client and server development. It has minimal dependencies (no boost), is very simple to use and support everything you'll likely need for websocket dev (SSL, deflate compression, compiles on most platforms, etc...). HTTP client and server code is also available, but it hasn't received as much testing.
66

77
It is been used on big mobile video game titles sending and receiving tons of messages since 2017 (iOS and Android). It was tested on macOS, iOS, Linux, Android, Windows and FreeBSD. Two important design goals are simplicity and correctness.
88

99
```cpp
10-
# Required on Windows
10+
// Required on Windows
1111
ix::initNetSystem();
1212

13-
# Our websocket object
13+
// Our websocket object
1414
ix::WebSocket webSocket;
1515

1616
std::string url("ws://localhost:8080/");
@@ -34,8 +34,8 @@ webSocket.start();
3434
webSocket.send("hello world");
3535
```
3636

37-
Interested ? Go read the [docs](https://machinezone.github.io/IXWebSocket/) ! If things don't work as expected, please create an issue in github, or even better a pull request if you know how to fix your problem.
37+
Interested? Go read the [docs](https://machinezone.github.io/IXWebSocket/)! If things don't work as expected, please create an issue on GitHub, or even better a pull request if you know how to fix your problem.
3838

39-
IXWebSocket is actively being developed, check out the [changelog](CHANGELOG.md) to know what's cooking. If you are looking for a real time messaging service (the chat-like 'server' your websocket code will talk to) with many features such as history, backed by Redis, look at [cobra](https://github.com/machinezone/cobra).
39+
IXWebSocket is actively being developed, check out the [changelog](https://machinezone.github.io/IXWebSocket/CHANGELOG/) to know what's cooking. If you are looking for a real time messaging service (the chat-like 'server' your websocket code will talk to) with many features such as history, backed by Redis, look at [cobra](https://github.com/machinezone/cobra).
4040

4141
IXWebSocket client code is autobahn compliant beginning with the 6.0.0 version. See the current [test results](https://bsergean.github.io/IXWebSocket/autobahn/index.html). Some tests are still failing in the server code.

docs/build.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ vcpkg install ixwebsocket
3333

3434
### Conan
3535

36-
Support for building with conan was contributed by Olivia Zoe (thanks !). The package name to reference is `IXWebSocket/5.0.0@LunarWatcher/stable`. The package is in the process to be published to the official conan package repo, but in the meantime, it can be accessed by adding a new remote
36+
Support for building with conan was contributed by Olivia Zoe (thanks!). The package name to reference is `IXWebSocket/5.0.0@LunarWatcher/stable`, and a list of the uploaded versions is available on [Bintray](https://bintray.com/oliviazoe0/conan-packages/IXWebSocket%3ALunarWatcher). The package is in the process to be published to the official conan package repo, but in the meantime, it can be accessed by adding a new remote
3737

3838
```
3939
conan remote add remote_name_here https://api.bintray.com/conan/oliviazoe0/conan-packages

docs/cobra.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Bring up 3 terminals and run a server, a publisher and a subscriber in each one.
88

99
You will need to have a redis server running locally. To run the server:
1010

11-
```
11+
```bash
1212
$ cd <ixwebsocket-top-level-folder>/ixsnake/ixsnake
1313
$ ws snake
1414
{
@@ -33,7 +33,7 @@ redis port: 6379
3333

3434
### Publisher
3535

36-
```
36+
```bash
3737
$ cd <ixwebsocket-top-level-folder>/ws
3838
$ ws cobra_publish --appkey FC2F10139A2BAc53BB72D9db967b024f --endpoint ws://127.0.0.1:8008 --rolename _pub --rolesecret 1c04DB8fFe76A4EeFE3E318C72d771db test_channel cobraMetricsSample.json
3939
[2019-11-27 09:06:12.980] [info] Publisher connected
@@ -49,7 +49,7 @@ $ ws cobra_publish --appkey FC2F10139A2BAc53BB72D9db967b024f --endpoint ws://127
4949

5050
### Subscriber
5151

52-
```
52+
```bash
5353
$ ws cobra_subscribe --appkey FC2F10139A2BAc53BB72D9db967b024f --endpoint ws://127.0.0.1:8008 --rolename _pub --rolesecret 1c04DB8fFe76A4EeFE3E318C72d771db test_channel
5454
#messages 0 msg/s 0
5555
[2019-11-27 09:07:39.341] [info] Subscriber connected

docs/design.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Large frames are broken up into smaller chunks or messages to avoid filling up t
2424

2525
The library has an interactive tool which is handy for testing compatibility ith other libraries. We have tested our client against Python, Erlang, Node.js, and C++ websocket server libraries.
2626

27-
The unittest tries to be comprehensive, and has been running on multiple platoform, with different sanitizers such as thread sanitizer to catch data races or the undefined behavior sanitizer.
27+
The unittest tries to be comprehensive, and has been running on multiple platforms, with different sanitizers such as a thread sanitizer to catch data races or the undefined behavior sanitizer.
2828

2929
The regression test is running after each commit on travis.
3030

docs/index.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414
## Example code
1515

16-
```
17-
# Required on Windows
16+
```cpp
17+
// Required on Windows
1818
ix::initNetSystem();
1919

20-
# Our websocket object
20+
// Our websocket object
2121
ix::WebSocket webSocket;
2222

2323
std::string url("ws://localhost:8080/");
@@ -40,12 +40,12 @@ webSocket.start();
4040
webSocket.send("hello world");
4141
```
4242

43-
## Why another library ?
43+
## Why another library?
4444

4545
There are 2 main reasons that explain why IXWebSocket got written. First, we needed a C++ cross-platform client library, which should have few dependencies. What looked like the most solid one, [websocketpp](https://github.com/zaphoyd/websocketpp) did depend on boost and this was not an option for us. Secondly, there were other available libraries with fewer dependencies (C ones), but they required calling an explicit poll routine periodically to know if a client had received data from a server, which was not elegant.
4646

4747
We started by solving those 2 problems, then we added server websocket code, then an HTTP client, and finally a very simple HTTP server.
4848

4949
## Contributing
5050

51-
IXWebSocket is developed on [github](https://github.com/machinezone/IXWebSocket). We'd love to hear about how you use it ; opening up an issue in github is ok for that. If things don't work as expected, please create an issue in github, or even better a pull request if you know how to fix your problem.
51+
IXWebSocket is developed on [GitHub](https://github.com/machinezone/IXWebSocket). We'd love to hear about how you use it; opening up an issue on GitHub is ok for that. If things don't work as expected, please create an issue on GitHub, or even better a pull request if you know how to fix your problem.

docs/usage.md

+20-20
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The [*ws*](https://github.com/machinezone/IXWebSocket/tree/master/ws) folder cou
66

77
To use the network system on Windows, you need to initialize it once with *WSAStartup()* and clean it up with *WSACleanup()*. We have helpers for that which you can use, see below. This init would typically take place in your main function.
88

9-
```
9+
```cpp
1010
#include <ixwebsocket/IXNetSystem.h>
1111

1212
int main()
@@ -22,12 +22,12 @@ int main()
2222

2323
## WebSocket client API
2424

25-
```
25+
```cpp
2626
#include <ixwebsocket/IXWebSocket.h>
2727

2828
...
2929

30-
# Our websocket object
30+
// Our websocket object
3131
ix::WebSocket webSocket;
3232

3333
std::string url("ws://localhost:8080/");
@@ -82,9 +82,9 @@ If the connection was closed and sending failed, the return value will be set to
8282

8383
### Open and Close notifications
8484

85-
The onMessage event will be fired when the connection is opened or closed. This is similar to the [Javascript browser API](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket), which has `open` and `close` events notification that can be registered with the browser `addEventListener`.
85+
The onMessage event will be fired when the connection is opened or closed. This is similar to the [JavaScript browser API](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket), which has `open` and `close` events notification that can be registered with the browser `addEventListener`.
8686

87-
```
87+
```cpp
8888
webSocket.setOnMessageCallback([](const ix::WebSocketMessagePtr& msg)
8989
{
9090
if (msg->type == ix::WebSocketMessageType::Open)
@@ -115,7 +115,7 @@ webSocket.setOnMessageCallback([](const ix::WebSocketMessagePtr& msg)
115115
116116
A message will be fired when there is an error with the connection. The message type will be `ix::WebSocketMessageType::Error`. Multiple fields will be available on the event to describe the error.
117117
118-
```
118+
```cpp
119119
webSocket.setOnMessageCallback([](const ix::WebSocketMessagePtr& msg)
120120
{
121121
if (msg->type == ix::WebSocketMessageType::Error)
@@ -140,7 +140,7 @@ webSocket.setOnMessageCallback([](const ix::WebSocketMessagePtr& msg)
140140

141141
The url can be set and queried after a websocket object has been created. You will have to call `stop` and `start` if you want to disconnect and connect to that new url.
142142

143-
```
143+
```cpp
144144
std::string url("wss://example.com");
145145
websocket.configure(url);
146146
```
@@ -149,7 +149,7 @@ websocket.configure(url);
149149
150150
Ping/pong messages are used to implement keep-alive. 2 message types exists to identify ping and pong messages. Note that when a ping message is received, a pong is instantly send back as requested by the WebSocket spec.
151151
152-
```
152+
```cpp
153153
webSocket.setOnMessageCallback([](const ix::WebSocketMessagePtr& msg)
154154
{
155155
if (msg->type == ix::WebSocketMessageType::Ping ||
@@ -163,7 +163,7 @@ webSocket.setOnMessageCallback([](const ix::WebSocketMessagePtr& msg)
163163

164164
A ping message can be sent to the server, with an optional data string.
165165

166-
```
166+
```cpp
167167
websocket.ping("ping data, optional (empty string is ok): limited to 125 bytes long");
168168
```
169169

@@ -173,15 +173,15 @@ You can configure an optional heart beat / keep-alive, sent every 45 seconds
173173
when there is no any traffic to make sure that load balancers do not kill an
174174
idle connection.
175175

176-
```
176+
```cpp
177177
webSocket.setHeartBeatPeriod(45);
178178
```
179179

180180
### Supply extra HTTP headers.
181181

182182
You can set extra HTTP headers to be sent during the WebSocket handshake.
183183

184-
```
184+
```cpp
185185
WebSocketHttpHeaders headers;
186186
headers["foo"] = "bar";
187187
webSocket.setExtraHeaders(headers);
@@ -191,22 +191,22 @@ webSocket.setExtraHeaders(headers);
191191

192192
You can specify subprotocols to be set during the WebSocket handshake. For more info you can refer to [this doc](https://hpbn.co/websocket/#subprotocol-negotiation).
193193

194-
```
194+
```cpp
195195
webSocket.addSubprotocol("appProtocol-v1");
196196
webSocket.addSubprotocol("appProtocol-v2");
197197
```
198198

199199
The protocol that the server did accept is available in the open info `protocol` field.
200200

201-
```
201+
```cpp
202202
std::cout << "protocol: " << msg->openInfo.protocol << std::endl;
203203
```
204204

205205
### Automatic reconnection
206206

207207
Automatic reconnection kicks in when the connection is disconnected without the user consent. This feature is on by default and can be turned off.
208208

209-
```
209+
```cpp
210210
webSocket.enableAutomaticReconnection(); // turn on
211211
webSocket.disableAutomaticReconnection(); // turn off
212212
bool enabled = webSocket.isAutomaticReconnectionEnabled(); // query state
@@ -239,7 +239,7 @@ Wait time(ms): 10000
239239

240240
The waiting time is capped by default at 10s between 2 attempts, but that value can be changed and queried.
241241

242-
```
242+
```cpp
243243
webSocket.setMaxWaitBetweenReconnectionRetries(5 * 1000); // 5000ms = 5s
244244
uint32_t m = webSocket.getMaxWaitBetweenReconnectionRetries();
245245
```
@@ -253,7 +253,7 @@ Then, secure sockets are automatically used when connecting to a `wss://*` url.
253253
Additional TLS options can be configured by passing a `ix::SocketTLSOptions` instance to the
254254
`setTLSOptions` on `ix::WebSocket` (or `ix::WebSocketServer` or `ix::HttpServer`)
255255

256-
```
256+
```cpp
257257
webSocket.setTLSOptions({
258258
.certFile = "path/to/cert/file.pem",
259259
.keyFile = "path/to/key/file.pem",
@@ -279,7 +279,7 @@ For a server, specifying `caFile` implies that:
279279

280280
## WebSocket server API
281281

282-
```
282+
```cpp
283283
#include <ixwebsocket/IXWebSocketServer.h>
284284

285285
...
@@ -344,7 +344,7 @@ server.wait();
344344

345345
## HTTP client API
346346

347-
```
347+
```cpp
348348
#include <ixwebsocket/IXHttpClient.h>
349349

350350
...
@@ -427,7 +427,7 @@ bool ok = httpClient.performRequest(args, [](const HttpResponsePtr& response)
427427

428428
## HTTP server API
429429

430-
```
430+
```cpp
431431
#include <ixwebsocket/IXHttpServer.h>
432432

433433
ix::HttpServer server(port, hostname);
@@ -445,7 +445,7 @@ server.wait();
445445
446446
If you want to handle how requests are processed, implement the setOnConnectionCallback callback, which takes an HttpRequestPtr as input, and returns an HttpResponsePtr. You can look at HttpServer::setDefaultConnectionCallback for a slightly more advanced callback example.
447447
448-
```
448+
```cpp
449449
setOnConnectionCallback(
450450
[this](HttpRequestPtr request,
451451
std::shared_ptr<ConnectionState> /*connectionState*/) -> HttpResponsePtr

docs/ws.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,4 +245,4 @@ Options:
245245

246246
## Cobra Client
247247

248-
[cobra](https://github.com/machinezone/cobra) is a real time messenging server. ws has sub-command to interacti with cobra.
248+
[cobra](https://github.com/machinezone/cobra) is a real time messenging server. ws has a sub-command to interact with cobra.

0 commit comments

Comments
 (0)