Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
934 views
in Technique[技术] by (71.8m points)

npm - how to create and run my own peerjs server?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...