Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added code shine for ruby commander viewer HTML Push example.

  • Loading branch information...
commit 50ca892e01d65f3f7dcc0b9b026a23e81253f5bf 1 parent dfd3951
@stephenlb stephenlb authored
Showing with 10 additions and 27 deletions.
  1. +3 −6 ruby/commander/commander.rb
  2. +7 −21 ruby/commander/viewer.html
View
9 ruby/commander/commander.rb
@@ -16,13 +16,10 @@
## Send Message (PUBLISH)
## ----------------------
while 1
- puts('Sending a message with publish() To Content Viewer')
- info = pubnub.publish({
+ puts('Sending a HTML via PUBNUB...')
+ pubnub.publish({
'channel' => 'content_commander',
- 'message' => {
- 'name' => 'arb_html',
- 'data' => "Current Time: <h1>" + Time.now.inspect + "</h1>"
- }
+ 'message' => "Current Time: <h1>" + Time.now.inspect + "</h1>"
})
sleep(1.0)
end
View
28 ruby/commander/viewer.html
@@ -16,7 +16,7 @@
<div data-role="content" id="viewer_box" class="box left">
<div id="content"></div>
</div><!-- /content #viewer_box" -->
- </div>
+ </div>
<!-- JQUERY -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
@@ -26,28 +26,14 @@
<div sub-key="a71204b3-ca89-11df-ba32-cfcef4a2b967" ssl="off" origin="pubsub.pubnub.com" id="pubnub"></div>
<script src="http://cdn.pubnub.com/pubnub-3.1.min.js"></script>
<script>(function(){
- $(document).data('uuid', (((1+Math.random())*0x10000)|0).toString(16).substring(1));
-
- PUBNUB.events.bind('arb_html', function(html) {
- $("#content").remove();
- $("#viewer_box").append("<div id='content'>"+ html + "</div>");
- });
PUBNUB.subscribe({
- channel : "content_commander",
- restore : false,
- callback : function(message) {
- if (message.name) {
- PUBNUB.events.fire(message.name, message.data);
- }
- },
- disconnect : function() {
- console.log("Connection Lost.");
- },
- reconnect : function() {
- console.log("And we're Back!");
- }
-
+ channel : "content_commander",
+ restore : false,
+ callback : function(html) {
+ $("#content").remove();
+ $("#viewer_box").append("<div id='content'>"+ html + "</div>");
+ },
});
})();</script>
Please sign in to comment.
Something went wrong with that request. Please try again.