0

How to put the juggernaut push messages to show it in html in browser? thanks in advance..

Aditya Hadi
  • 364
  • 1
  • 4
  • 17

1 Answers1

0

It's all documented here: https://github.com/maccman/juggernaut

Assume you have your Juggernaut server is setup and running and your app is publishing messages to Redis.

Let's assume you are publishing messages to channel1

Your html code should include the following javascript files (which come with Juggernaut):

<script src="/javascripts/json.js" type="text/javascript"></script> 
<script src="/javascripts/socket_io.js" type="text/javascript"></script> 
<script src="/javascripts/juggernaut.js" type="text/javascript"></script>

And following that you should connect to the Juggernaut server and handle incoming messages

<script type="text/javascript" charset="utf-8">
  // Connect to Juggernaut
  var jug = new Juggernaut({secure: ('https:' == document.location.protocol)});

  // Log the fact we have connected
  jug.on("connect", function(){ log("Connected") });

  // Log disconnection
  jug.on("disconnect", function(){ log("Disconnected") });

  // Log reconnection
  jug.on("reconnect", function(){ log("Reconnecting") });

  jug.subscribe("channel1", function(data){
    // Your code to handle the incoming message
  });

  // Expose for debugging
  window.jug = jug;
</script>

Again a full end to end example is provided in the README on github

lebreeze
  • 5,094
  • 26
  • 34