diff options
Diffstat (limited to 'lib/assets/javascripts/cable/consumer.js.coffee')
-rw-r--r-- | lib/assets/javascripts/cable/consumer.js.coffee | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/assets/javascripts/cable/consumer.js.coffee b/lib/assets/javascripts/cable/consumer.js.coffee new file mode 100644 index 0000000000..b9c08807f2 --- /dev/null +++ b/lib/assets/javascripts/cable/consumer.js.coffee @@ -0,0 +1,18 @@ +#= require cable/connection +#= require cable/connection_monitor +#= require cable/subscription +#= require cable/subscriber_manager + +class Cable.Consumer + constructor: (@url) -> + @subscribers = new Cable.SubscriberManager this + @connection = new Cable.Connection this + @connectionMonitor = new Cable.ConnectionMonitor this + + createSubscription: (channelName, mixin) -> + channel = channelName + params = if typeof channel is "object" then channel else {channel} + new Cable.Subscription this, params, mixin + + send: (data) -> + @connection.send(data) |