Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It looks like you need to follow the guide on the Juggernaut readme under that line titled Basic Usage.</p> <blockquote> <p>Basic usage</p> <p>Everything in Juggernaut is done within the context of a channel. JavaScript clients can subscribe to a channel which your server can publish to. First, we need to include Juggernaut's application.js file. By default, Juggernaut is hosted on port 8080 - so we can just link to the file there.</p> <pre><code>&lt;script src="http://localhost:8080/application.js" </code></pre> <p>type="text/javascript" charset="utf-8"></p> <p>We then need to instantiate the Juggernaut object and subscribe to the channel. As you can see, subscribe takes two arguments, the channel name and a callback.</p> <pre><code>&lt;script type="text/javascript" charset="utf-8"&gt; var jug = new Juggernaut; jug.subscribe("channel1", function(data){ console.log("Got data: " + data); }); &lt;/script&gt; </code></pre> <p>That's it for the client side. Now, to publish to the channel we'll write some Ruby:</p> <pre><code>require "juggernaut" Juggernaut.publish("channel1", "Some data") </code></pre> <p>You should see the data we sent appear instantly in the open browser window. As well as strings, we can even pass objects, like so:</p> <pre><code>Juggernaut.publish("channel1", {:some =&gt; "data"}) </code></pre> <p>The publish method also takes an array of channels, in case you want to send a message to multiple channels co-currently.</p> <pre><code>Juggernaut.publish(["channel1", "channel2"], ["foo", "bar"]) </code></pre> <p>That's pretty much the gist of it, the two methods - publish and subscribe. Couldn't be easier than that!</p> </blockquote> <p>Once you have that done you can implement the Ruby code mentioned above inside a controller which takes the user input from a form and then calls something like <code>Juggernaut.publish("channel1", @user_data)</code> allowing your users to send data through the server to each other. ` </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload