gritzko / swarm

JavaScript replicated model (M of MVC) library
http://swarmdb.net/
MIT License
2.68k stars 97 forks source link

Pass options through to Einaros websockets. #48

Closed rolandpoulter closed 9 years ago

rolandpoulter commented 9 years ago

Changed this so I could use a self-signed certificate with wss://. Here is a code snippet:

// CLIENT
swarm_host = new swarm.Host(config.get('client_id'));
var url = 'wss://' + config.get('local_server');
var opts = { ca: [pem.server_cert] };
swarm_host.connect(url, opts); // TODO: passing opts.ca requires modifications to Swarm
swarm.env.localhost = swarm_host;
// SERVER
var https_server = https.createServer({
  cert: pem.server_cert,
  key: pem.server_key,
});
https_server.listen(port, function (err)  {});
var wss_server = new ws.Server({ server: https_server });
wss_server.on('connection', function (ws) {});