How to create and run your own peerjs server?

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

$> 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 is the difference between the above steps. when and where to use these steps.

+5
source share
2 answers

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 using nodejs /root/node_modules/peer/node_modules/ws/index.js

+7
source

There are several ways to get a peerjs server:

  • npm install peer

  • git clone https://github.com/peers/peerjs-server

  • download and unzip the zip file from git

After that, go to <path_to_peerjs-server>/bin and run peerjs-server with the command:

 node peerjs --port 9000 --key peerjs 

or

 ./peerjs --port 9000 --key peerjs 

peerjs-server has more options, and you can see them with the ./peerjs command ./peerjs no arguments.

0
source

Source: https://habr.com/ru/post/1204699/


All Articles