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.