Ruby on Rails
Monday, May 6, 2019
That first "App.awpchan.send({message: 'This is a cool chat app.'});" does not make sense. Did you edit my answer on stackoverflow? It looks messed up, why did you change it? I had both issues split on two parts on my answer on purpose to be explicit on which fixes which issue. I don't think the actual edit is an improvement on my original answer.
El lun., 6 may. 2019 a las 14:24, <robert.phillips37@gmail.com> escribió:
Thanks for the tips--I got it working making sure that at the client I put the send line in the connect function so it didn't try to send before connecting, and I passed in a dictionary object.app/assets/javascripts/theawpchan.js
App.awpchan.send({message: 'This is a cool chat app.'});App.awpchan = App.cable.subscriptions.create("AwpchanChannel", {connected: function() {App.awpchan.send({message: 'This is a cool chat app.'});},disconnected: function() {},received: function(data) {return alert(data);}});And I added the receive method at the server side..app/channels/awpchan_channel.rbclass AwpchanChannel < ApplicationCable::Channeldef subscribedstream_from "abcdstrm"enddef unsubscribed# Any cleanup needed when channel is unsubscribedenddef receive(data)puts data["message"]endend
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-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@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.
For more options, visit https://groups.google.com/d/optout.
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-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcAFZHabL3wLy6J0%3DpwRb81NHhKs%2Bqwi%3DMVQfAaHSFrZyA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment