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

4
4
5
5
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.
6
6
7
7
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.
8
8
9
9
```cpp
10
-
# Required on Windows
10
+
// Required on Windows
11
11
ix::initNetSystem();
12
12
13
-
# Our websocket object
13
+
// Our websocket object
14
14
ix::WebSocket webSocket;
15
15
16
16
std::string url("ws://localhost:8080/");
@@ -34,8 +34,8 @@ webSocket.start();
34
34
webSocket.send("hello world");
35
35
```
36
36
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.
38
38
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).
40
40
41
41
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.
Copy file name to clipboardexpand all lines: docs/build.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ vcpkg install ixwebsocket
33
33
34
34
### Conan
35
35
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
Copy file name to clipboardexpand all lines: docs/design.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ Large frames are broken up into smaller chunks or messages to avoid filling up t
24
24
25
25
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.
26
26
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.
28
28
29
29
The regression test is running after each commit on travis.
Copy file name to clipboardexpand all lines: docs/index.md
+5-5
Original file line number
Diff line number
Diff line change
@@ -13,11 +13,11 @@
13
13
14
14
## Example code
15
15
16
-
```
17
-
# Required on Windows
16
+
```cpp
17
+
// Required on Windows
18
18
ix::initNetSystem();
19
19
20
-
# Our websocket object
20
+
// Our websocket object
21
21
ix::WebSocket webSocket;
22
22
23
23
std::string url("ws://localhost:8080/");
@@ -40,12 +40,12 @@ webSocket.start();
40
40
webSocket.send("hello world");
41
41
```
42
42
43
-
## Why another library?
43
+
## Why another library?
44
44
45
45
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.
46
46
47
47
We started by solving those 2 problems, then we added server websocket code, then an HTTP client, and finally a very simple HTTP server.
48
48
49
49
## Contributing
50
50
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.
Copy file name to clipboardexpand all lines: docs/usage.md
+20-20
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ The [*ws*](https://github.com/machinezone/IXWebSocket/tree/master/ws) folder cou
6
6
7
7
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.
8
8
9
-
```
9
+
```cpp
10
10
#include<ixwebsocket/IXNetSystem.h>
11
11
12
12
intmain()
@@ -22,12 +22,12 @@ int main()
22
22
23
23
## WebSocket client API
24
24
25
-
```
25
+
```cpp
26
26
#include<ixwebsocket/IXWebSocket.h>
27
27
28
28
...
29
29
30
-
# Our websocket object
30
+
// Our websocket object
31
31
ix::WebSocket webSocket;
32
32
33
33
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
82
82
83
83
### Open and Close notifications
84
84
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`.
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.
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.
142
142
143
-
```
143
+
```cpp
144
144
std::string url("wss://example.com");
145
145
websocket.configure(url);
146
146
```
@@ -149,7 +149,7 @@ websocket.configure(url);
149
149
150
150
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.
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).
193
193
194
-
```
194
+
```cpp
195
195
webSocket.addSubprotocol("appProtocol-v1");
196
196
webSocket.addSubprotocol("appProtocol-v2");
197
197
```
198
198
199
199
The protocol that the server did accept is available in the open info `protocol` field.
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.
0 commit comments