Ruby on Rails Friday, April 19, 2019

The received method is called when the client receives data from the server, if you want to know if the client is sending the data properly to the server check the server log. The received method is not supposed to be called when the client sends a message to the server.

El vie., 19 abr. 2019 08:38, <robert.phillips37@gmail.com> escribió:
I am trying to use action cable. 

I got the server to send to the client. But I also want the client to send to the server.

I tried this in my coffeescript file

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.'


but that last line isn't working

that last line doesn't seem to cause an alert, so it doesn't seem to trigger the received method

I know the alert line works though because when sending a message from server to client, I trigger it.   (I have a line in my controller broadcasting a message to the channel and that triggers the alert fine).

It's just that the last line in the coffeescript, which is meant to send from client to server, is not triggering that received method, / is not causing an alert.

Thanks

--
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/72e7ca5b-11fa-4163-8626-a990f1b63bd8%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/CAPS3bcAkdo6xw_dh%2Bi691eEa2921rzWenmJ80EL6A0xaddCoLA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment