how to create and run my own peerjs server?

John picture John · Oct 15, 2014 · Viewed 11.5k times · Source

I got the following code from the git-hub but I don't know how to use and execute.

 $> npm install peer   --->where i want to install this node_module ?
  //Run the server:

 $> peerjs --port 9000 --key peerjs     
         or
 var PeerServer = require('peer').PeerServer;
 var server = new PeerServer({port: 9000, path: '/myapp'});

what's the difference between above steps. when and where to use those steps.

Answer

Socke picture Socke · Feb 15, 2015

After npm install peer go to /root/node_modules/peer/node_modules/ws. Then add something like

var PeerServer = require('peer').PeerServer;
var server = PeerServer({port: 443, path: '/peerjs'});

in index.js and start the server with nodejs /root/node_modules/peer/node_modules/ws/index.js