Saturday, 29 April 2017

Using ws and wss simultaneously

I am trying to get both ws and wss working, on one WebSocket server.

This is what I currently have, only wss

var WebSocket = require('ws');
var https = require('https');

var privateKey = fs.readFileSync('cert/s.agar.yt.key');
var certificate = fs.readFileSync('cert/s.agar.yt.crt');

var httpsServer = https.createServer({
    ca: ca,
    key: privateKey,
    cert: certificate
}, this.app);

var options = {
    server: httpsServer, 
    perMessageDeflate: false,
    maxPayload: 4096
};

var wss = new WebSocket.Server(options);

I know using Socket.io it is really easy, you can just do io.attach(httpServer) and io.attach(httpsServer).

Is this even possible, using this WebSocket library?



via Joery

No comments:

Post a Comment