aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/lib/assets/javascripts
diff options
context:
space:
mode:
Diffstat (limited to 'actioncable/lib/assets/javascripts')
-rw-r--r--actioncable/lib/assets/javascripts/action_cable.coffee.erb (renamed from actioncable/lib/assets/javascripts/cable.coffee.erb)6
-rw-r--r--actioncable/lib/assets/javascripts/action_cable/connection.coffee (renamed from actioncable/lib/assets/javascripts/cable/connection.coffee)4
-rw-r--r--actioncable/lib/assets/javascripts/action_cable/connection_monitor.coffee (renamed from actioncable/lib/assets/javascripts/cable/connection_monitor.coffee)4
-rw-r--r--actioncable/lib/assets/javascripts/action_cable/consumer.coffee31
-rw-r--r--actioncable/lib/assets/javascripts/action_cable/subscription.coffee (renamed from actioncable/lib/assets/javascripts/cable/subscription.coffee)6
-rw-r--r--actioncable/lib/assets/javascripts/action_cable/subscriptions.coffee (renamed from actioncable/lib/assets/javascripts/cable/subscriptions.coffee)12
-rw-r--r--actioncable/lib/assets/javascripts/cable/consumer.coffee31
7 files changed, 47 insertions, 47 deletions
diff --git a/actioncable/lib/assets/javascripts/cable.coffee.erb b/actioncable/lib/assets/javascripts/action_cable.coffee.erb
index a722f27ac1..7daea4ebcd 100644
--- a/actioncable/lib/assets/javascripts/cable.coffee.erb
+++ b/actioncable/lib/assets/javascripts/action_cable.coffee.erb
@@ -1,11 +1,11 @@
#= require_self
-#= require cable/consumer
+#= require action_cable/consumer
-@Cable =
+@ActionCable =
INTERNAL: <%= ActionCable::INTERNAL.to_json %>
createConsumer: (url = @getConfig("url")) ->
- new Cable.Consumer @createWebSocketURL(url)
+ new ActionCable.Consumer @createWebSocketURL(url)
getConfig: (name) ->
element = document.head.querySelector("meta[name='action-cable-#{name}']")
diff --git a/actioncable/lib/assets/javascripts/cable/connection.coffee b/actioncable/lib/assets/javascripts/action_cable/connection.coffee
index b2abe8dcb2..2f69a9b26c 100644
--- a/actioncable/lib/assets/javascripts/cable/connection.coffee
+++ b/actioncable/lib/assets/javascripts/action_cable/connection.coffee
@@ -1,8 +1,8 @@
# Encapsulate the cable connection held by the consumer. This is an internal class not intended for direct user manipulation.
-{message_types} = Cable.INTERNAL
+{message_types} = ActionCable.INTERNAL
-class Cable.Connection
+class ActionCable.Connection
@reopenDelay: 500
constructor: (@consumer) ->
diff --git a/actioncable/lib/assets/javascripts/cable/connection_monitor.coffee b/actioncable/lib/assets/javascripts/action_cable/connection_monitor.coffee
index 435efcc361..b594802be1 100644
--- a/actioncable/lib/assets/javascripts/cable/connection_monitor.coffee
+++ b/actioncable/lib/assets/javascripts/action_cable/connection_monitor.coffee
@@ -1,13 +1,13 @@
# Responsible for ensuring the cable connection is in good health by validating the heartbeat pings sent from the server, and attempting
# revival reconnections if things go astray. Internal class, not intended for direct user manipulation.
-class Cable.ConnectionMonitor
+class ActionCable.ConnectionMonitor
@pollInterval:
min: 3
max: 30
@staleThreshold: 6 # Server::Connections::BEAT_INTERVAL * 2 (missed two pings)
- identifier: Cable.INTERNAL.identifiers.ping
+ identifier: ActionCable.INTERNAL.identifiers.ping
constructor: (@consumer) ->
@consumer.subscriptions.add(this)
diff --git a/actioncable/lib/assets/javascripts/action_cable/consumer.coffee b/actioncable/lib/assets/javascripts/action_cable/consumer.coffee
new file mode 100644
index 0000000000..5cf8978d77
--- /dev/null
+++ b/actioncable/lib/assets/javascripts/action_cable/consumer.coffee
@@ -0,0 +1,31 @@
+#= require action_cable/connection
+#= require action_cable/connection_monitor
+#= require action_cable/subscriptions
+#= require action_cable/subscription
+
+# The ActionCable.Consumer establishes the connection to a server-side Ruby Connection object. Once established,
+# the ActionCable.ConnectionMonitor will ensure that its properly maintained through heartbeats and checking for stale updates.
+# The Consumer instance is also the gateway to establishing subscriptions to desired channels through the #createSubscription
+# method.
+#
+# The following example shows how this can be setup:
+#
+# @App = {}
+# App.cable = ActionCable.createConsumer "ws://example.com/accounts/1"
+# App.appearance = App.cable.subscriptions.create "AppearanceChannel"
+#
+# For more details on how you'd configure an actual channel subscription, see ActionCable.Subscription.
+class ActionCable.Consumer
+ constructor: (@url) ->
+ @subscriptions = new ActionCable.Subscriptions this
+ @connection = new ActionCable.Connection this
+ @connectionMonitor = new ActionCable.ConnectionMonitor this
+
+ send: (data) ->
+ @connection.send(data)
+
+ inspect: ->
+ JSON.stringify(this, null, 2)
+
+ toJSON: ->
+ {@url, @subscriptions, @connection, @connectionMonitor}
diff --git a/actioncable/lib/assets/javascripts/cable/subscription.coffee b/actioncable/lib/assets/javascripts/action_cable/subscription.coffee
index 5b024d4e15..339d676933 100644
--- a/actioncable/lib/assets/javascripts/cable/subscription.coffee
+++ b/actioncable/lib/assets/javascripts/action_cable/subscription.coffee
@@ -1,4 +1,4 @@
-# A new subscription is created through the Cable.Subscriptions instance available on the consumer.
+# A new subscription is created through the ActionCable.Subscriptions instance available on the consumer.
# It provides a number of callbacks and a method for calling remote procedure calls on the corresponding
# Channel instance on the server side.
#
@@ -23,7 +23,7 @@
#
# This is how the server component would look:
#
-# class AppearanceChannel < ApplicationCable::Channel
+# class AppearanceChannel < ApplicationActionCable::Channel
# def subscribed
# current_user.appear
# end
@@ -43,7 +43,7 @@
#
# The "AppearanceChannel" name is automatically mapped between the client-side subscription creation and the server-side Ruby class name.
# The AppearanceChannel#appear/away public methods are exposed automatically to client-side invocation through the @perform method.
-class Cable.Subscription
+class ActionCable.Subscription
constructor: (@subscriptions, params = {}, mixin) ->
@identifier = JSON.stringify(params)
extend(this, mixin)
diff --git a/actioncable/lib/assets/javascripts/cable/subscriptions.coffee b/actioncable/lib/assets/javascripts/action_cable/subscriptions.coffee
index 7955565f06..0316f76a24 100644
--- a/actioncable/lib/assets/javascripts/cable/subscriptions.coffee
+++ b/actioncable/lib/assets/javascripts/action_cable/subscriptions.coffee
@@ -1,12 +1,12 @@
# Collection class for creating (and internally managing) channel subscriptions. The only method intended to be triggered by the user
-# us Cable.Subscriptions#create, and it should be called through the consumer like so:
+# us ActionCable.Subscriptions#create, and it should be called through the consumer like so:
#
# @App = {}
-# App.cable = Cable.createConsumer "ws://example.com/accounts/1"
+# App.cable = ActionCable.createConsumer "ws://example.com/accounts/1"
# App.appearance = App.cable.subscriptions.create "AppearanceChannel"
#
-# For more details on how you'd configure an actual channel subscription, see Cable.Subscription.
-class Cable.Subscriptions
+# For more details on how you'd configure an actual channel subscription, see ActionCable.Subscription.
+class ActionCable.Subscriptions
constructor: (@consumer) ->
@subscriptions = []
@history = []
@@ -14,7 +14,7 @@ class Cable.Subscriptions
create: (channelName, mixin) ->
channel = channelName
params = if typeof channel is "object" then channel else {channel}
- new Cable.Subscription this, params, mixin
+ new ActionCable.Subscription this, params, mixin
# Private
@@ -63,7 +63,7 @@ class Cable.Subscriptions
sendCommand: (subscription, command) ->
{identifier} = subscription
- if identifier is Cable.INTERNAL.identifiers.ping
+ if identifier is ActionCable.INTERNAL.identifiers.ping
@consumer.connection.isOpen()
else
@consumer.send({command, identifier})
diff --git a/actioncable/lib/assets/javascripts/cable/consumer.coffee b/actioncable/lib/assets/javascripts/cable/consumer.coffee
deleted file mode 100644
index 05a7398e79..0000000000
--- a/actioncable/lib/assets/javascripts/cable/consumer.coffee
+++ /dev/null
@@ -1,31 +0,0 @@
-#= require cable/connection
-#= require cable/connection_monitor
-#= require cable/subscriptions
-#= require cable/subscription
-
-# The Cable.Consumer establishes the connection to a server-side Ruby Connection object. Once established,
-# the Cable.ConnectionMonitor will ensure that its properly maintained through heartbeats and checking for stale updates.
-# The Consumer instance is also the gateway to establishing subscriptions to desired channels through the #createSubscription
-# method.
-#
-# The following example shows how this can be setup:
-#
-# @App = {}
-# App.cable = Cable.createConsumer "ws://example.com/accounts/1"
-# App.appearance = App.cable.subscriptions.create "AppearanceChannel"
-#
-# For more details on how you'd configure an actual channel subscription, see Cable.Subscription.
-class Cable.Consumer
- constructor: (@url) ->
- @subscriptions = new Cable.Subscriptions this
- @connection = new Cable.Connection this
- @connectionMonitor = new Cable.ConnectionMonitor this
-
- send: (data) ->
- @connection.send(data)
-
- inspect: ->
- JSON.stringify(this, null, 2)
-
- toJSON: ->
- {@url, @subscriptions, @connection, @connectionMonitor}