diff options
Diffstat (limited to 'lib/assets')
-rw-r--r-- | lib/assets/javascripts/cable/subscriptions.js.coffee | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/assets/javascripts/cable/subscriptions.js.coffee b/lib/assets/javascripts/cable/subscriptions.js.coffee index fe6975c870..eeaa697081 100644 --- a/lib/assets/javascripts/cable/subscriptions.js.coffee +++ b/lib/assets/javascripts/cable/subscriptions.js.coffee @@ -9,6 +9,7 @@ class Cable.Subscriptions constructor: (@consumer) -> @subscriptions = [] + @history = [] create: (channelName, mixin) -> channel = channelName @@ -49,6 +50,10 @@ class Cable.Subscriptions for subscription in subscriptions subscription[callbackName]?(args...) + if callbackName in ["initialized", "connected", "disconnected"] + {identifier} = subscription + @record(notification: {identifier, callbackName, args}) + sendCommand: (subscription, command) -> {identifier} = subscription if identifier is Cable.PING_IDENTIFIER @@ -56,5 +61,11 @@ class Cable.Subscriptions else @consumer.send({command, identifier}) + record: (data) -> + data.time = new Date() + @history = @history.slice(-19) + @history.push(data) + toJSON: -> - subscription.identifier for subscription in @subscriptions + history: @history + identifiers: (subscription.identifier for subscription in @subscriptions) |