Socket
Socket
Sign inDemoInstall

html5-websocket

Package Overview
Dependencies
4
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    html5-websocket

HTML5 WebSocket for node.js


Version published
Weekly downloads
274
decreased by-11.9%
Maintainers
1
Install size
157 kB
Created
Weekly downloads
 

Readme

Source

DEPRECATED

:warning: Consider this library as deprecated. It was created to expose ws with a WebSocket interface. This is no longer needed because latest versions of ws already implement this interface.


html5-websocket

This module implements the standard HTML5 WebSocket API as a thin layer over the great ws library.

The motivation behind this module is to be able to write WebSocket based libraries that will run without changes in Node.js, Browsers or React Native apps.

Install

npm install --save html5-websocket

Usage

The API is the same as the standard HTML5 Socket API so nothing new here...

const WebSocket = require('html5-websocket');

const ws = new WebSocket('ws://html5rocks.websocket.org/echo');

ws.onopen = function () {
    ws.send('Hello!');
};

ws.onmessage = function (e) {
    console.log(e.data);
};

ws.onerror = function (error) {
    console.log('Fail:', error);
};

You can also use the DOM Level 2 Event Model

const handleMessage = function (e) {
    console.log(e.data);
};

// add listener
ws.addEventListener('message', handleMessage);

// remove listener
ws.removeEventListener('message', handleMessage);

License

MIT

Keywords

FAQs

Last updated on 30 Sep 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc