PageRenderTime 16ms CodeModel.GetById 10ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/js/lib/Socket.IO-node/support/node-websocket-client/README.md

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
Markdown | 41 lines | 28 code | 13 blank | 0 comment | 0 complexity | 48e2e5988dda4cb6b7e896b0a1c719fc MD5 | raw file
 1A prototype [Web Socket](http://www.whatwg.org/specs/web-socket-protocol/)
 2client implementation for [node.js](http://nodejs.org).
 3
 4Tested with
 5[miksago/node-websocket-server](http://github.com/miksago/node-websocket-server)
 6v1.2.00.
 7
 8Requires [nodejs](http://nodejs.org) 0.1.98 or later.
 9
10## Installation
11
12Install this using `npm` as follows
13
14    npm install websocket-client
15
16... or just dump `lib/websocket.js` in your `$NODE_PATH`.
17
18## Usage
19
20    var sys = require('sys');
21    var WebSocket = require('websocket').WebSocket;
22
23    var ws = new WebSocket('ws://localhost:8000/biff', 'borf');
24    ws.addListener('data', function(buf) {
25        sys.debug('Got data: ' + sys.inspect(buf));
26    });
27    ws.onmessage = function(m) {
28        sys.debug('Got message: ' + m);
29    }
30
31## API
32
33This supports the `send()` and `onmessage()` APIs. The `WebSocket` object will
34also emit `data` events that are node `Buffer` objects, in case you want to
35work with something lower-level than strings.
36
37## Transports
38
39Multiple transports are supported, indicated by the scheme provided to the
40`WebSocket` constructor. `ws://` is a standard TCP-based Web Socket;
41`ws+unix://` allows connection to a UNIX socket at the given path.