blob: 16c49b559abc75ac50260ebdf4d83ebfbca4569c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#= 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)
inspect: ->
JSON.stringify(this, null, 2)
toJSON: ->
{@subscribers, @connection, @connectionMonitor}
|