Socket
Socket
Sign inDemoInstall

websocketio

Package Overview
Dependencies
4
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    websocketio

WebSocket high-level abstraction


Version published
Weekly downloads
8
increased by300%
Maintainers
1
Install size
186 kB
Created
Weekly downloads
 

Readme

Source

websocketio

WebSocket high-level abstraction

Use

  • Simlar programming style to packages such as socket.io
  • Send JSON objects as Strings or Binary data as ArrayBuffers
  • Support for external applications (Python, C++)
  • Fast streaming for high-performance networking

Client side JS: https://rawgit.com/tmarrinan/websocketio/master/example/public/src/websocketio.js

Dependencies

  • Python
    • tornado: install with pip install tornado
  • C++
    • websocketpp: initialize with git submodule update --init
    • boost c++ libraries
var WebSocketIO = require('websocketio');

var server = http.createServer(...);
var wsioServer = new WebSocketIO.Server({server: server});
wsioServer.onconnection(openWebSocketClient);

function openWebSocketClient(wsio) {
	console.log("Client connect: "+ wsio.id);
	wsio.onclose(closeWebSocketClient);

	wsio.on('requestJSONMessage', wsRequestJSONMessage);
	wsio.on('broadcastToAllClients', wsBroadcastToAllClients);
}

function closeWebSocketClient(wsio) {
	console.log("Client disconnect: "+ wsio.id);
}

function wsRequestJSONMessage(wsio, data) {
	wsio.emit('JSONMessage', {foo: "hello", bar: "world"});
}

function wsBroadcastToAllClients(wsio, data) {
	wsioServer.broadcast('dataFromClient', data); // sends to all connected clients who are listening to message 'dataFromClient'
}


server.listen(8000, "0.0.0.0");
console.log("Now listening on port 8000");

Keywords

FAQs

Last updated on 05 Jan 2022

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