how to create and run my own peerjs server?

江枫思渺然 提交于 2019-11-29 03:37:32

问题


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.


回答1:


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




回答2:


There are few ways to get peerjs-server:

  1. npm install peer

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

  3. download and unpack zip-file from git

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

node peerjs --port 9000 --key peerjs

or

./peerjs --port 9000 --key peerjs

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



来源:https://stackoverflow.com/questions/26374931/how-to-create-and-run-my-own-peerjs-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!