1.2.1 • Published 2 years ago

websocketio v1.2.1

Weekly downloads
12
License
BSD-3-Clause
Repository
github
Last release
2 years ago

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");
1.2.1

2 years ago

1.2.0

2 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago