O'Reilly logo

PhoneGap By Example by Andrey Kovalenko

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building a real-time communication application with PeerJS

Now, we can do the same, but with the help of the PeerJS library. In the previous example, you may notice that we can do a call only between two peers. In the following example, we will show you how we can initiate a call between more than two peers.

PeerJS is a wrapper for the browser's WebRTC implementation. It is aimed to simplify the peer-to-peer connection management. PeerJS provides a functionality to list the connected clients.

Server side

We will create a simple Node.js application with peer module. For example, we will add two modules: peer and ip. We can do this with the following commands:

$ npm install peer --save
$ npm install ip --save

After this installation, the package.json ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required