sockjs-websockify

SockJS connection wrapper. Makes connections more web socket like.

Usage no npm install needed!

<script type="module">
  import sockjsWebsockify from 'https://cdn.skypack.dev/sockjs-websockify';
</script>

README

sockjs-websockify

Wrapper around SockJS connections. Makes them more web socket like.

Sadly sockjs-node connections have different API than web sockets. ㅜㅜ

Installation

$ npm install sockjs-websockify

Usage


var http        = require('http'),
    sockjs      = require('sockjs'),
    websockify  = require('sockjs-websockify'),
    wss         = sockjs.createServer();

wss.on('connection', function(conn) {

    // wrap the connection to act more like a websocket.
    var socket = websockify(conn);

    socket.send('hello');
    socket.addEventListener('message', console.log.bind(console));
});

var server = http.createServer();
wss.installHandlers(server, { prefix:'/sockjs' });
server.listen(3000, '0.0.0.0');