Produced by Araxis Merge on 7/26/2017 10:13:33 AM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | C:\AraxisMergeCompare\Pri_un\TAR\ws-1.1.0\package | README.md | Mon Apr 11 11:59:50 2016 UTC |
| 2 | C:\AraxisMergeCompare\Pri_re\TAR\ws-1.1.0\package | README.md | Wed Jul 26 14:55:45 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 468 |
| Changed | 1 | 2 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | # ws: a no de.js webs ocket libr ary | |
| 2 | ||
| 3 | [](https:/ /travis-ci .org/webso ckets/ws) | |
| 4 | ||
| 5 | `ws` is a simple to use WebSoc ket implem entation, up-to-date against R FC-6455, | |
| 6 | and [proba bly the fa stest WebS ocket libr ary for no de.js][arc hive]. | |
| 7 | ||
| 8 | Passes the quite ext ensive Aut obahn test suite. Se e http://w ebsockets. github.com /ws | |
| 9 | for the fu ll reports . | |
| 10 | ||
| 11 | ## Protoco l support | |
| 12 | ||
| 13 | * **Hixie draft 76** (Old and deprecated , but stil l in use b y Safari a nd Opera. | |
| 14 | Added to ws versio n 0.4.2, b ut server only. Can be disable d by setti ng the | |
| 15 | `disable Hixie` opt ion to tru e.) | |
| 16 | * **HyBi d rafts 07-1 2** (Use t he option `protocolV ersion: 8` ) | |
| 17 | * **HyBi d rafts 13-1 7** (Curre nt default , alternat ively opti on `protoc olVersion: 13`) | |
| 18 | ||
| 19 | ### Instal ling | |
| 20 | ||
| 21 | ``` | |
| 22 | npm instal l --save w s | |
| 23 | ``` | |
| 24 | ||
| 25 | ### Opt-in for perfo rmance | |
| 26 | ||
| 27 | There are 2 optional modules t hat can be installed along sid e with the `ws` | |
| 28 | module. Th ese module s are bina ry addons which impr ove certai n operatio ns, but as | |
| 29 | they are b inary addo ns they re quire comp ilation wh ich can fa il if no c ++ | |
| 30 | compiler i s installe d on the h ost system . | |
| 31 | ||
| 32 | - `npm ins tall --sav e bufferut il`: Impro ves intern al buffer operations which | |
| 33 | allows f or faster processing of masked WebSocket frames an d general buffer | |
| 34 | operatio ns. | |
| 35 | - `npm ins tall --sav e utf-8-va lidate`: T he specifi cation req uires vali dation of | |
| 36 | invalid UTF-8 char s, some of these val idations c ould not b e done in JavaScript | |
| 37 | hence th e need for a binary addon. In most cases you will already be | |
| 38 | validati ng the inp ut that yo u receive for securi ty purpose s leading to double | |
| 39 | validati on. But if you want to be 100% spec-conf orming and have fast | |
| 40 | validati on of UTF- 8 then thi s module i s a must. | |
| 41 | ||
| 42 | ### Sendin g and rece iving text data | |
| 43 | ||
| 44 | ```js | |
| 45 | var WebSoc ket = requ ire('ws'); | |
| 46 | var ws = n ew WebSock et('ws://w ww.host.co m/path'); | |
| 47 | ||
| 48 | ws.on('ope n', functi on open() { | |
| 49 | ws.send( 'something '); | |
| 50 | }); | |
| 51 | ||
| 52 | ws.on('mes sage', fun ction(data , flags) { | |
| 53 | // flags .binary wi ll be set if a binar y data is received. | |
| 54 | // flags .masked wi ll be set if the dat a was mask ed. | |
| 55 | }); | |
| 56 | ``` | |
| 57 | ||
| 58 | ### Sendin g binary d ata | |
| 59 | ||
| 60 | ```js | |
| 61 | var WebSoc ket = requ ire('ws'); | |
| 62 | var ws = n ew WebSock et('ws://w ww.host.co m/path'); | |
| 63 | ||
| 64 | ws.on('ope n', functi on open() { | |
| 65 | var arra y = new Fl oat32Array (5); | |
| 66 | ||
| 67 | for (var i = 0; i < array.le ngth; ++i) { | |
| 68 | array[ i] = i / 2 ; | |
| 69 | } | |
| 70 | ||
| 71 | ws.send( array, { b inary: tru e, mask: t rue }); | |
| 72 | }); | |
| 73 | ``` | |
| 74 | ||
| 75 | Setting `m ask`, as d one for th e send opt ions above , will cau se the dat a to be | |
| 76 | masked acc ording to the WebSoc ket protoc ol. The sa me option applies fo r text | |
| 77 | data. | |
| 78 | ||
| 79 | ### Server example | |
| 80 | ||
| 81 | ```js | |
| 82 | var WebSoc ketServer = require( 'ws').Serv er | |
| 83 | , wss = new WebSoc ketServer( { port: 80 80 }); | |
| 84 | ||
| 85 | wss.on('co nnection', function connection (ws) { | |
| 86 | ws.on('m essage', f unction in coming(mes sage) { | |
| 87 | consol e.log('rec eived: %s' , message) ; | |
| 88 | }); | |
| 89 | ||
| 90 | ws.send( 'something '); | |
| 91 | }); | |
| 92 | ``` | |
| 93 | ||
| 94 | ### Expres sJS exampl e | |
| 95 | ||
| 96 | ```js | |
| 97 | var server = require ('http').c reateServe r() | |
| 98 | , url = require('u rl') | |
| 99 | , WebSoc ketServer = require( 'ws').Serv er | |
| 100 | , wss = new WebSoc ketServer( { server: server }) | |
| 101 | , expres s = requir e('express ') | |
| 102 | , app = express() | |
| 103 | , port = PORT ; | |
| 104 | ||
| 105 | app.use(fu nction (re q, res) { | |
| 106 | res.send ({ msg: "h ello" }); | |
| 107 | }); | |
| 108 | ||
| 109 | wss.on('co nnection', function connection (ws) { | |
| 110 | var loca tion = url .parse(ws. upgradeReq .url, true ); | |
| 111 | // you m ight use l ocation.qu ery.access _token to authentica te or shar e sessions | |
| 112 | // or ws .upgradeRe q.headers. cookie (se e http://s tackoverfl ow.com/a/1 6395220/15 1312) | |
| 113 | ||
| 114 | ws.on('m essage', f unction in coming(mes sage) { | |
| 115 | consol e.log('rec eived: %s' , message) ; | |
| 116 | }); | |
| 117 | ||
| 118 | ws.send( 'something '); | |
| 119 | }); | |
| 120 | ||
| 121 | server.on( 'request', app); | |
| 122 | server.lis ten(port, function ( ) { consol e.log('Lis tening on ' + server .address() .port) }); | |
| 123 | ``` | |
| 124 | ||
| 125 | ### Server sending b roadcast d ata | |
| 126 | ||
| 127 | ```js | |
| 128 | var WebSoc ketServer = require( 'ws').Serv er | |
| 129 | , wss = new WebSoc ketServer( { port: 80 80 }); | |
| 130 | ||
| 131 | wss.broadc ast = func tion broad cast(data) { | |
| 132 | wss.clie nts.forEac h(function each(clie nt) { | |
| 133 | client .send(data ); | |
| 134 | }); | |
| 135 | }; | |
| 136 | ``` | |
| 137 | ||
| 138 | ### Error handling b est practi ces | |
| 139 | ||
| 140 | ```js | |
| 141 | // If the WebSocket is closed before the following send is a ttempted | |
| 142 | ws.send('s omething') ; | |
| 143 | ||
| 144 | // Errors (both imme diate and async writ e errors) can be det ected in a n optional | |
| 145 | // callbac k. The cal lback is a lso the on ly way of being noti fied that data has | |
| 146 | // actuall y been sen t. | |
| 147 | ws.send('s omething', function ack(error) { | |
| 148 | // if er ror is not defined, the send h as been co mpleted, | |
| 149 | // other wise the e rror objec t will ind icate what failed. | |
| 150 | }); | |
| 151 | ||
| 152 | // Immedia te errors can also b e handled with try/c atch-block s, but **n ote** that | |
| 153 | // since s ends are i nherently asynchrono us, socket write fai lures will *not* be | |
| 154 | // capture d when thi s techniqu e is used. | |
| 155 | try { ws.s end('somet hing'); } | |
| 156 | catch (e) { /* handl e error */ } | |
| 157 | ``` | |
| 158 | ||
| 159 | ### echo.w ebsocket.o rg demo | |
| 160 | ||
| 161 | ```js | |
| 162 | var WebSoc ket = requ ire('ws'); | |
| 163 | var ws = n ew WebSock et('ws://e cho.websoc ket.org/', { | |
| 164 | protocol Version: 8 , | |
| 165 | origin: 'http://we bsocket.or g' | |
| 166 | }); | |
| 167 | ||
| 168 | ws.on('ope n', functi on open() { | |
| 169 | console. log('conne cted'); | |
| 170 | ws.send( Date.now() .toString( ), {mask: true}); | |
| 171 | }); | |
| 172 | ||
| 173 | ws.on('clo se', funct ion close( ) { | |
| 174 | console. log('disco nnected'); | |
| 175 | }); | |
| 176 | ||
| 177 | ws.on('mes sage', fun ction mess age(data, flags) { | |
| 178 | console. log('Round trip time: ' + (Date .now() - p arseInt(da ta)) + 'ms ', flags); | |
| 179 | ||
| 180 | setTimeo ut(functio n timeout( ) { | |
| 181 | ws.sen d(Date.now ().toStrin g(), {mask : true}); | |
| 182 | }, 500); | |
| 183 | }); | |
| 184 | ``` | |
| 185 | ||
| 186 | ### Other examples | |
| 187 | ||
| 188 | For a full example w ith a brow ser client communica ting with a ws serve r, see the | |
| 189 | examples f older. | |
| 190 | ||
| 191 | Note that the usage together w ith Expres s 3.0 is q uite diffe rent from Express | |
| 192 | 2.x. The d ifference is express ed in the two differ ent server stats-exam ples. | |
| 193 | ||
| 194 | Otherwise, see the t est cases. | |
| 195 | ||
| 196 | ### Runnin g the test s | |
| 197 | ||
| 198 | ``` | |
| 199 | make test | |
| 200 | ``` | |
| 201 | ||
| 202 | ## API Doc s | |
| 203 | ||
| 204 | See [`/doc /ws.md`](h ttps://git hub.com/we bsockets/w s/blob/mas ter/doc/ws .md) for N ode.js-lik e docs for the ws cl asses. | |
| 205 | ||
| 206 | ## Changel og | |
| 207 | ||
| 208 | We're usin g the GitH ub [`relea ses`](http s://github .com/webso ckets/ws/r eleases) f or changel og entries . | |
| 209 | ||
| 210 | ## License | |
| 211 | ||
| 212 | (The MIT L icense) | |
| 213 | ||
| 214 | Copyright (c) 2011 E inar Otto Stangvik & lt;einaros @gmail.com > | |
| 215 | ||
| 216 | Permission is hereby granted, free of ch arge, to a ny person obtaining | |
| 217 | a copy of this softw are and as sociated d ocumentati on files ( the | |
| 218 | 'Software' ), to deal in the So ftware wit hout restr iction, in cluding | |
| 219 | without li mitation t he rights to use, co py, modify , merge, p ublish, | |
| 220 | distribute , sublicen se, and/or sell copi es of the Software, and to | |
| 221 | permit per sons to wh om the Sof tware is f urnished t o do so, s ubject to | |
| 222 | the follow ing condit ions: | |
| 223 | ||
| 224 | The above copyright notice and this perm ission not ice shall be | |
| 225 | included i n all copi es or subs tantial po rtions of the Softwa re. | |
| 226 | ||
| 227 | THE SOFTWA RE IS PROV IDED 'AS I S', WITHOU T WARRANTY OF ANY KI ND, | |
| 228 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LI MITED TO T HE WARRANT IES OF | |
| 229 | MERCHANTAB ILITY, FIT NESS FOR A PARTICULA R PURPOSE AND NONINF RINGEMENT. | |
| 230 | IN NO EVEN T SHALL TH E AUTHORS OR COPYRIG HT HOLDERS BE LIABLE FOR ANY | |
| 231 | CLAIM, DAM AGES OR OT HER LIABIL ITY, WHETH ER IN AN A CTION OF C ONTRACT, | |
| 232 | TORT OR OT HERWISE, A RISING FRO M, OUT OF OR IN CONN ECTION WIT H THE | |
| 233 | SOFTWARE O R THE USE OR OTHER D EALINGS IN THE SOFTW ARE. | |
| 234 | ||
| 235 | [archive]: http://we b.archive. org/web/20 1303142305 36/http:// hobbycodin g.posterou s.com/the- fastest-we bsocket-mo dule-for-n odejs |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.