I want to access data from a websocket stream. I can't get ActionCable to bind the message received function. If I hack cable.js then I can see the data by adding:
App.cable = ActionCable.createConsumer("ws://localhost:7000");
App.cable.connect();
App.cable.connection.webSocket.onmessage = function(event) { console.log(event); };
Otherwise I keep getting an error message which is generated every time a message is received:
/app/assets/javascripts/channels/markets.coffee
App.markets = App.cable.subscriptions.create { channel: "MarketsChannel" },
connected: ->
console.log("connected");
disconnected: ->
received: (data) ->
console.log("Test");
/app/assets/javascripts/cable.js
//= require action_cable
//= require_self
//= require_tree ./channels
(function() {
this.App || (this.App = {});
App.cable = ActionCable.createConsumer("ws://localhost:7000");
//App.cable.connect();
//App.cable.connection.webSocket.onmessage = function(event) { console.log(event); };
}).call(this);
Plus this other standard files from the generator.
Why is everything so hard....?