Want more content like this?

Sponsors love

WebRTC is a powerful idea. It aims at establishing real-time communication inside of a browser. Google, Mozilla and Opera carry the project, its API is supported in Chrome and the nightly versions of Firefox. Does this sound limited? It sure does. The JavaScript project Peer.js is even more limited. It is only functional, not even fully, in Chrome Dev and Canary. Still it is an interesting approach to guess on the future of communication.

Well, you could go pier to pier here. But that isn’t what we are talking about…

Peer.js – Client-Side with Server-Side-Support

Peer.js wraps WebRTC and allows for establishing peer connections between two clients based on unique IDs. The system needs a server-side installation, the so-called PeerServer, which can be established using node.js. On the client-side Peer.js is integrated as a library. The PeerServer is only needed to connect the peers, any communication that occurs after connect happens directly between the peers.

As WebRTC only sees lukewarm support even in Chrome, Peer.js today is nothing more than an experiment. Its perspectives are good though. I would go as far as proclaiming that its success is a mere matter of time. At least as far as the functionality is concerned. If it will be exactly Peer.js or coming under a different name still has to be seen..

Screenshot: Peer.js Homepage

Right at this moment the project has not a lot more to offer than a demo of a chat. You’ll need to know and enter the above-mentioned unique ID to connect. Handling of IDs would be a matter of programming of course, so let’s not bemoan this demo as desultory. As the project is a hatchling, a little patience should be expectable.

Peer.js – Basic Mode of Operation

Integration of Peer.js is no big thing. The bigger thing is to constitute the PeerServer. On the side of the client the script is implemented like this:

A peer gets defined this way:

And the peer with the desire to connect shows up like this:

If you want to approach Peer.js without having to put lots of effort into it, you will want to omit to establish a PeerServer on your own behalf. Thanks to the developers of Peer.js you can. They offer a PeerServer as a cloud service, free of charge for developers.

If you get eager to build your own eMule environment that way, calm down. The size of data to be shared via Peer.js is extremely limited. Only sizes less than 1 kB are working, yet not even reliably. Don’t blame Peer.js though. This is another flaw in the browser implementation of WebRTC.

Peer.js is maintained by the two Berkeley students Michelle Bu and Eric Zhang. Zhang was part of the startup Flotype which now lives on under a different name. Zhang is no longer part of it, still he is a skilled JavaScript developer.

Social love

Dieter Petereit is a veteran of the web with over 25 years of experience in the world of IT. As soon as Netscape became available he started to do what already at that time was called web design and has carried on ever since. Two decades ago he started writing for several online publications, some well, some lesser known. You can meet him over on Google+.