Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 65 lines (48 sloc) 2.465 kb
1d8000a @einaros initial import
einaros authored
1 # easy-websocket #
2
3 `easy-websocket` aims to be a easy to use websocket client, up-to-date against current HyBi protocol versions.
4
5 ## Usage ##
6
7 ### Sending and receiving text data ###
8
9 ```js
10 var ws = new WebSocket('ws://www.host.com/path');
11 ws.on('connected', function() {
12 ws.send('something');
13 });
14 ws.on('message', function(message, flags) {
15 // flags.binary will be set if a binary message is received
16 // flags.masked will be set if the message was masked
17 });
18 ```
19
20 ### Sending binary data ###
21
22 ```js
23 var ws = new WebSocket('ws://www.host.com/path');
24 ws.on('connected', function() {
25 var array = new Float32Array(5);
26 for (var i = 0; i < array.length; ++i) array[i] = i / 2;
27 ws.send(array, {binary: true, mask: true});
28 });
29 ```
30
31 Setting `mask`, as done for the send options above, will cause the message to be masked according to the websocket protocol. The same option applies for text messages.
32
33 ### Other examples ###
34
35 See the test cases.
36
37 ## Yet to be done ##
38
39 - While the receiver does support fragmentation, the sender does currently not do fragmentation -- even for large data pieces. Ideally streams can be transmitted using fragmentation.
40 - More tests should be written for the receiving bits, such as for `close`; although these are implicitly tested already since the testserver shares the same receiver.
41
42 ## License ##
43
44 (The MIT License)
45
46 Copyright (c) 2011 Einar Otto Stangvik &lt;einaros@gmail.com&gt;
47
48 Permission is hereby granted, free of charge, to any person obtaining
49 a copy of this software and associated documentation files (the
50 'Software'), to deal in the Software without restriction, including
51 without limitation the rights to use, copy, modify, merge, publish,
52 distribute, sublicense, and/or sell copies of the Software, and to
53 permit persons to whom the Software is furnished to do so, subject to
54 the following conditions:
55
56 The above copyright notice and this permission notice shall be
57 included in all copies or substantial portions of the Software.
58
59 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
60 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
61 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
62 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
63 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
64 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
65 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Something went wrong with that request. Please try again.