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.
PeerJS provides an open source implementation of this connection broker server PeerJS Server (written in Node. js), in case you do not want to use their cloud-hosted version (which is free right now, and comes with some limitations).
But there is some good news; PeerJS is a WebRTC framework that abstracts away all of the ice and signalling logic so that you can focus on the functionality of your application. There are two parts to PeerJS, the client-side framework and the server.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With