0.1.9 • Published 6 years ago

kk-websocket v0.1.9

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

kk-websocket

Version npm Linux Build Windows Build Coverage Status

__Work in Progress. Not Complete.__

Wrapper of ws and WebSocket.

It uses:

Limitations

Before using this module you should know that ws is not perfectly API compatible with WebSocket, you should always test your code against both Node and browsers.

Some major differences:

  • no Server implementation in browsers

Usage

You need to install both this package and ws:

> npm i kk-websocket ws

Then just require this package:

const WebSocket = require('kk-websocket')

const ws = new WebSocket('wss://echo.websocket.org/', {
  origin: 'https://websocket.org'
});

ws.on('open', function open() {
  console.log('connected');
  ws.send(Date.now());
});

ws.on('close', function close() {
  console.log('disconnected');
});

ws.on('message', function incoming(data) {
  console.log(`Roundtrip time: ${Date.now() - data} ms`);

  setTimeout(function timeout() {
    ws.send(Date.now());
  }, 500);
});

Files

  • .travis.yml(Travis CI) npm run coveralls
  • package.json(NPM)
    • prepublishOnly nps test clean build
    • coveralls npm run coverage && ./node_modules/coveralls/bin/coveralls.js < ./coverage/lcov.info
    • coverage
      istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec --exit
    • test nps test
    • start nps
  • package-scripts.js(NPS)
    • build
    • lint
    • clean
    • test
      • node
      • browser
      • bundle
    • coveralls
    • prebuildDocs
    • buildDocs
    • postbuildDocs
    • prewatchDocs
    • watchDocs
  • karma.conf.js(Karma)
0.1.9

6 years ago

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago