diff options
Diffstat (limited to 'lib/assets')
4 files changed, 17 insertions, 0 deletions
diff --git a/lib/assets/javascripts/cable/connection.js.coffee b/lib/assets/javascripts/cable/connection.js.coffee index 4d2c1018aa..2e7a9930ec 100644 --- a/lib/assets/javascripts/cable/connection.js.coffee +++ b/lib/assets/javascripts/cable/connection.js.coffee @@ -71,3 +71,6 @@ class Cable.Connection error: -> @consumer.subscribers.notifyAll("disconnected") @closeSilently() + + toJSON: -> + state: @getState() diff --git a/lib/assets/javascripts/cable/connection_monitor.js.coffee b/lib/assets/javascripts/cable/connection_monitor.js.coffee index fc5093c5eb..ea0c360b75 100644 --- a/lib/assets/javascripts/cable/connection_monitor.js.coffee +++ b/lib/assets/javascripts/cable/connection_monitor.js.coffee @@ -55,6 +55,11 @@ class Cable.ConnectionMonitor else secondsSince(@startedAt) > @staleThreshold.startedAt + toJSON: -> + interval = @getInterval() + connectionIsStale = @connectionIsStale() + {@startedAt, @stoppedAt, @pingedAt, @reconnectAttempts, connectionIsStale, interval} + now = -> new Date().getTime() diff --git a/lib/assets/javascripts/cable/consumer.js.coffee b/lib/assets/javascripts/cable/consumer.js.coffee index b9c08807f2..16c49b559a 100644 --- a/lib/assets/javascripts/cable/consumer.js.coffee +++ b/lib/assets/javascripts/cable/consumer.js.coffee @@ -16,3 +16,9 @@ class Cable.Consumer send: (data) -> @connection.send(data) + + inspect: -> + JSON.stringify(this, null, 2) + + toJSON: -> + {@subscribers, @connection, @connectionMonitor} diff --git a/lib/assets/javascripts/cable/subscriber_manager.js.coffee b/lib/assets/javascripts/cable/subscriber_manager.js.coffee index 0b6a16590c..1eef98ff0b 100644 --- a/lib/assets/javascripts/cable/subscriber_manager.js.coffee +++ b/lib/assets/javascripts/cable/subscriber_manager.js.coffee @@ -36,3 +36,6 @@ class Cable.SubscriberManager @consumer.connection.isOpen() else @consumer.send({command, identifier}) + + toJSON: -> + subscriber.identifier for subscriber in @subscribers |