blob: 645a44e14015ab5b15f15f8ecb68373fec39da72 (
plain) (
tree)
|
|
class Cable.Channel
constructor: (@cable, params = {}, mixin) ->
@identifier = JSON.stringify(params)
extend(this, mixin)
@cable.subscribers.add(@identifier, this)
# Perform a channel action with the optional data passed as an attribute
sendAction: (action, data = {}) ->
data.action = action
@sendMessage(data)
sendMessage: (data) ->
@cable.sendMessage(@identifier, JSON.stringify(data))
unsubscribe: ->
@cable.subscribers.remove(@identifier)
extend = (object, properties) ->
if properties?
for key, value of properties
object[key] = value
object
|