I built a very simple app using Rails 5 beta 1 and ActionCable to show when users come online and let them send messages to each other.
Now, I would basically like to take the client-side part of ActionCable, implement it in the context of another app (that does not run on Rails 5) and connect it with the first app to send and receive data (such as the online status of users or messages).
To send data from that second app, I assume, I can simply make an AJAX POST request. The question is: How do I subscribe from my second app to an open connection of the first app?
Or even: How do I subscribe to the ActionCable connection of my Rails app from another app via API?
My guess is, I essentially want to include this coffeescript somehow in my second app:
App.appearance = App.cable.subscriptions.create "AppearanceChannel",
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) ->
# ...
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…