Realtime Data Stream with PubNub

Tomomi Imura, @girlie_mac

Realtime Data Stream with PubNub

cover

What We Do

Data

Data Stream

SDKs

HTTP Request & Response

HTTP Request & Response

Data Stream

JavaScript Examples

Super Simple Chat App

Include PubNub CDN


<script src="//cdn.pubnub.com/pubnub.min.js"></script>

<input id="input" placeholder="enter your message">
<p>Chat Output:</p>
<section id="output"></section>

Initialize


var pubnub = PUBNUB.init({
  subscribe_key: 'sub-c-f762fb78-2724-11e4-a4df-.........',
  publish_key: 'pub-c-156a6d5f-22bd-4a13-848d-.........'
});

Subscribe

Receiving messages and display


var channel = 'chat';

pubnub.subscribe({
    channel  : channel,
    callback : function(m) { 
      output.innerHTML = m.text.replace( /[<>]/ig, '' )  + '
' + output.innerHTML; } });

Publish

Sending a message


input.addEventListener('keyup', function(e) {
    (e.keyCode || e.charCode) === 13 && 
      pubnub.publish({
        channel : channel, 
        message : input.value
      })
}, false);
		

Live Demo

Join the chat - http://goo.gl/vlaOKy

http://goo.gl/vlaOKy

http://pubnub.github.io/tweet-emotion/

Node.js Hotness

More Use Cases

Multiplayer Games

Realtime Analytics • Data Vis

Home Automation • IoT

Interactive Advertising

Realtime Location • Tracking Vehicles

Community Involvement

Next Events at PubNub

Thank you!

Tomomi Imura @ PubNub

pubnub.com
@pubnub
@girlie_mac
github.com/pubnub

Photo Credit