|
8 | 8 | </div> |
9 | 9 |
|
10 | 10 | #### In a nutshell. |
11 | | -µWebSockets.js is the Google V8 bindings to [µWebSockets](https://github.com/uNetworking/uWebSockets), one of the most efficient web servers available for C++ programming<sup>[[2]](https://github.com/uNetworking/uWebSockets/tree/master/benchmarks)</sup>. Bypassing the entire I/O stack of Node.js allows for unprecedented efficiency in back-end JavaScript - what you build stands on nothing but the best of C and C++. Scales to millions of active WebSockets using half a GB of user space memory<sup>[[3]](https://medium.com/@alexhultman/millions-of-active-websockets-with-node-js-7dc575746a01)</sup>. |
12 | 11 |
|
13 | | -``` |
14 | | -npm install uNetworking/uWebSockets.js#v15.9.0 |
15 | | -``` |
16 | | - |
17 | | -, or any such tag (see [releases](https://github.com/uNetworking/uWebSockets.js/releases)). |
18 | | - |
19 | | - |
20 | | -#### Simple. |
21 | 12 | There are tons of [examples](examples) but here's the gist of it all: |
22 | 13 |
|
23 | 14 | ```javascript |
24 | | -const uWS = require('uWebSockets.js'); |
| 15 | +/* Non-SSL is simply App() */ |
| 16 | +require('uWebSockets.js').SSLApp({ |
25 | 17 |
|
26 | | -/* Non-SSL is simply uWS.App() */ |
27 | | -uWS.SSLApp({ |
28 | 18 | /* There are tons of SSL options */ |
29 | 19 | key_file_name: 'misc/key.pem', |
30 | 20 | cert_file_name: 'misc/cert.pem', |
| 21 | + |
31 | 22 | }).ws('/*', { |
| 23 | + |
32 | 24 | /* For brevity we skip the other events */ |
33 | 25 | message: (ws, message, isBinary) => { |
34 | 26 | let ok = ws.send(message, isBinary); |
35 | 27 | } |
| 28 | + |
36 | 29 | }).any('/*', (res, req) => { |
| 30 | + |
37 | 31 | /* Let's deny all Http */ |
38 | 32 | res.end('Nothing to see here!'); |
| 33 | + |
39 | 34 | }).listen(9001, (listenSocket) => { |
| 35 | + |
40 | 36 | if (listenSocket) { |
41 | 37 | console.log('Listening to port 9001'); |
42 | 38 | } |
| 39 | + |
43 | 40 | }); |
44 | 41 | ``` |
45 | 42 |
|
| 43 | +#### Ready all thrusters. |
| 44 | + |
| 45 | +Install with `npm install uNetworking/uWebSockets.js#v15.10.0` or any such [release](https://github.com/uNetworking/uWebSockets.js/releases). No compiler needed. |
| 46 | + |
| 47 | + |
| 48 | + |
46 | 49 | #### Pay what you want. |
47 | 50 | Commercially developed on a sponsored/consulting basis; BitMEX, Bitfinex and Coinbase are current or previous sponsors. Contact [me, the author](https://github.com/alexhultman) for support, feature development or consulting/contracting. |
48 | 51 |
|
49 | 52 |  |
50 | 53 |
|
| 54 | +#### Know thy legal matters. |
| 55 | + |
51 | 56 | *µWebSockets.js is intellectual property licensed Apache 2.0 with limitations on trademark use. Forks must be clearly labelled as such and must not be confused with the original.* |
0 commit comments