aboutsummaryrefslogtreecommitdiffstats
path: root/lib/assets/javascripts/cable.js.coffee
blob: 0f1d7c87732e2dfca889d5427b487c01fc3b8029 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#= require_self
#= require cable/subscriber_manager
#= require cable/connection
#= require cable/channel

class @Cable
  @PING_IDENTIFIER: "_ping"

  constructor: (@url) ->
    @subscribers = new Cable.SubscriberManager this
    @connection = new Cable.Connection this

  createChannel: (channelName, mixin) ->
    channel = channelName
    params = if typeof channel is "object" then channel else {channel}
    new Cable.Channel this, params, mixin

  send: (data) ->
    @connection.send(data)