aboutsummaryrefslogblamecommitdiffstats
path: root/lib/assets/javascripts/cable/consumer.js.coffee
blob: a9abd6256a0054ef289c63bc3c60350ab62d47e1 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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)