-
Notifications
You must be signed in to change notification settings - Fork 4
Home
gavit edited this page Sep 13, 2010
·
21 revisions
- Install Twister 1
- Install Orbited 2
- If you will use an external stomp server, download the orbited.cfg
- Don’t forget to edit config/orbited.yml which comes with the plugin
- Install stomp
gem install stomp
- Install the orbited plugin
cd YOUR_APP && script/plugin install git://github.com/mallio/orbited
- Go to your app directory and start the server
cd YOUR_APP && script/sever
- Start up orbited
orbited --config=config/orbited.cfg
- If you chose to use an external stomp server, start the external stomp server
class MyController < ApplicationController
def add_line
data = render_to_string :update do |page|
page["#chat"].append params[:entry] #Assuming you use JQuery
end
Orbited.send_data('hello', data)
end
end
Assuming you use JQuery.
form_remote_tag #TODO replace with JQuery code
<%= orbited_javascript #TODO Shouldn't need to include prototype when using JQuery %> <%= stomp_connect('hello', :js => :jquery, :callbacks => { :onopen => "function() { alert('Opening stomp client'); }", :onclose => "function(c) { alert('Lost Connection, Code: ' + c); }", :onerror => "function(error){ alert('onError: ' + error); }", :onmessageframe => "function(frame) { alert(frame.body); eval(frame.body); }", :onreceiptframe => "function(frame) { alert('onReceiptFrame: '+ frame) }", :onerrorframe => "function(error){ alert('onErrorFrame: ' + error); }", :onlinereceived => "function(line) {alert('onLineReceived: ' + line);}", :onrawdatareceived => "function(data) {alert('onRawDataReceived: ' + data);}" } ) %>
< div id=“chat” style=“height:300px;border:1px solid black;overflow:scroll;”>< /div>
<%- form_remote_tag :url => {:controller => ‘participants’, :action => :add_line}, :method => :put do>end -%>
<= text_field_tag ‘entry’ >
<= submit_tag (‘Send’) >
<
map.resources :MyController, :collection => { :add_line => :put}