Free up to 1MM monthly messages. No credit card required.
The WebRTC Peer Connection makes a direct connection between two browsers so they can pass data between them. Though WebRTC is known for its audio and video capabilities, we at PubNub are interested in the Data Channel API. The Data Channel allows the passing of arbitrary data across this connection. This means your users can now share data directly with each other. This secure connection is great for applications that need to work with high performance and low latency communication such as fast action video games or large scale file sharing. For those that are familiar with establishing a peer connection the API is fairly simple:
We now have a way for our users to communicate directly with each other at no cost to the developer! The Data Channel API currently supports most generic forms of data including strings, blobs, and array data. This makes it easy to share any piece of information encoded in your favorite flavor such as JSON or XML. The Data Channel also supports UDP which makes this the fastest speed you can get for sending data from one user to another.
Most readers are probably thinking, “Why would I ever use anything else ever again?” This connection may open up a number of possibilities, but no application is going to be comprised of only peer connections. There are still plenty of issues:
To investigate a lot of these issues, the team at PubNub built a WebRTC framework for making peer connections easily. We take all the guesswork out of sending SDP packets back and forth and give an easy to use API for sending data to another user. Because it’s all build on PubNub, there’s no need to set up any servers to make this happen. We went from hundreds of lines of code to a few simple steps:
Be sure to check out the getting started section on our GitHub page here: https://github.com/pubnub/webrtc
I personally believe this opens the doors for a lot of innovative web development. There are already great examples using the data channel such as file sharing applications and chat clients, including our P2P file-sharing app PubShare. We envision plenty of use cases for this technology like multiplayer games, networked storage systems, and more. This is even now opened up to Chrome for Android so my mobile phone can talk to other phones and desktops directly.
If you think of the average server setup, it’s hundreds of servers replicating and speaking to each other across the globe. Now if you think of the average client setup, it’s one browser talking to a few server endpoints.
Looking into the future, what if we could change this model and have our client integrate within our server mesh? Clients could share data with each other making the network faster and more robust. They could even share data with clients that are closer to them, rather than the nearest data center. Overall, this makes the web a better (and more streamlined) place for everybody.
Take a look at the top trends that are the most effective in attracting customers and reducing churn, and how you can incorporate...
Comparing the major game engines: Unity vs Unreal Engine vs Corona SDK vs GameMaker Studio, including the benefits and cons of...
Sockets (aka socket programming) enable programs to send and receive data, bi-directionally, at any given moment. This tutorial...