diff options
Diffstat (limited to 'lib/assets/javascripts/cable/consumer.js.coffee')
-rw-r--r-- | lib/assets/javascripts/cable/consumer.js.coffee | 16 |
1 files changed, 16 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..a9abd6256a --- /dev/null +++ b/lib/assets/javascripts/cable/consumer.js.coffee @@ -0,0 +1,16 @@ +#= require cable/connection +#= require cable/subscription +#= require cable/subscriber_manager + +class Cable.Consumer + constructor: (@url) -> + @subscribers = new Cable.SubscriberManager this + @connection = new Cable.Connection 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) |