PubNub SDK


The guys at PubNub have created a WebRTC SDK geared toward using the PubNub services as a signalling platform. The SDK is very comprehensive and provides a great insight into how to develop a WebRTC framework. You can view the demo of this SDK, here.

Using PubNub with XirSys (Part 1)

The PubNub WebRTC SDK provides a rather slick demo, which is set up to use the XirSys platform to provide STUN and TURN connectivity. To make use of it, you’ll first need to create an account with XirSys and one with PubNub, too, of course.

For the XirSys configuration, you’ll need your XirSys ident and secret key, as well as domain, application and room names which you can configure in the XirSys Dashboard. Once you’ve downloaded the SDK, go ahead and open the index.html file.

On line 196, you’ll find a function called get_xirsys_servers. This function houses the XirSys configuration, which you can populate with your own values.

              function get_xirsys_servers() {
                var servers;
                  type: 'POST',
                  url: '',
                  data: {
                    room: 'RoomName',
                    application: 'AppName',
                    domain: '',
                    ident: 'Username',
                    secret: 'SecretKey',
                  success: function(res) {
                    res = JSON.parse(res);
                    if (!res.e) servers = res.d.iceServers;
                  async: false
                return servers;

Configuring for PubNub signalling

You’ll need both your publish and subscribe keys for WebRTC signalling, as the WebRTC handshake is two way. You can provide these on line 158.

              var phone     = = PHONE({
              number        : my_number.number, // listen on this line
              publish_key   : '[publish_key]',
              subscribe_key : '[subscribe_key]',
              ssl           : true

To get your publish and subscribe keys, go ahead and register for free with PubNub. Once registered, you will be taken to a dashboard which will list both keys.

With this information in place, you can now run the demo. You can do this using your preferred web hosting software or simply by running the index.html file directly in a WebRTC compatible browser.

We hope this gives you a solid understanding of what it takes to bring these two awesome services together. Stay tuned for part 2 of this guide where we will explore more advanced possibilities.

Thank you and enjoy!