PageRenderTime 99ms CodeModel.GetById 85ms RepoModel.GetById 0ms app.codeStats 1ms

/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
Possible License(s): GPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. A prototype [Web Socket](http://www.whatwg.org/specs/web-socket-protocol/)
  2. client implementation for [node.js](http://nodejs.org).
  3. Tested with
  4. [miksago/node-websocket-server](http://github.com/miksago/node-websocket-server)
  5. v1.2.00.
  6. Requires [nodejs](http://nodejs.org) 0.1.98 or later.
  7. ## Installation
  8. Install this using `npm` as follows
  9. npm install websocket-client
  10. ... or just dump `lib/websocket.js` in your `$NODE_PATH`.
  11. ## Usage
  12. var sys = require('sys');
  13. var WebSocket = require('websocket').WebSocket;
  14. var ws = new WebSocket('ws://localhost:8000/biff', 'borf');
  15. ws.addListener('data', function(buf) {
  16. sys.debug('Got data: ' + sys.inspect(buf));
  17. });
  18. ws.onmessage = function(m) {
  19. sys.debug('Got message: ' + m);
  20. }
  21. ## API
  22. This supports the `send()` and `onmessage()` APIs. The `WebSocket` object will
  23. also emit `data` events that are node `Buffer` objects, in case you want to
  24. work with something lower-level than strings.
  25. ## Transports
  26. Multiple transports are supported, indicated by the scheme provided to the
  27. `WebSocket` constructor. `ws://` is a standard TCP-based Web Socket;
  28. `ws+unix://` allows connection to a UNIX socket at the given path.