App.hasdfg = App.cable.subscriptions.create "HasdfgChannel", connected: -> # Called when the subscription is ready for use on the server disconnected: -> # Called when the subscription has been terminated by the server received: (data) -> # Called when there's incoming data on the websocket for this channel alert(data); #App.hasdfg.send # sent_by: 'Paul' # body: 'This is a cool chat app.' #App.hasdfg.send # "yyy" App.hasdfg.send 'This is a cool chat app.'
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/72e7ca5b-11fa-4163-8626-a990f1b63bd8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
# app/channels/chat_channel.rb
class
ChatChannel < ApplicationCable::Channel
def
subscribed
stream_from
"chat_#{params[:room]}"
end
def
receive(data)
ActionCable.server.broadcast(
"chat_#{params[:room]}"
, data)
end
end
app/assets/javascripts/theawpchan.js
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3cc4c9bf-c54b-4ca5-bb64-3f36da22837a%40googlegroups.com.