diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2015-06-19 19:05:06 +0200 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2015-06-19 19:05:06 +0200 |
commit | 2258344e0fbeb1af74ebe477f392a76fa6d6f4ef (patch) | |
tree | 472e28efbd0c49e0136c506aa073690cf09591c0 | |
parent | 471ba41fddeff19f04f8d29bfe0df3c3f497407a (diff) | |
download | rails-2258344e0fbeb1af74ebe477f392a76fa6d6f4ef.tar.gz rails-2258344e0fbeb1af74ebe477f392a76fa6d6f4ef.tar.bz2 rails-2258344e0fbeb1af74ebe477f392a76fa6d6f4ef.zip |
Switch internal actions to be called commands instead, such that we can use action as the routing word on the user side
-rw-r--r-- | lib/action_cable/connection/base.rb | 2 | ||||
-rw-r--r-- | lib/assets/javascripts/cable.js.coffee | 6 | ||||
-rw-r--r-- | test/server_test.rb | 2 |
3 files changed, 5 insertions, 5 deletions
diff --git a/lib/action_cable/connection/base.rb b/lib/action_cable/connection/base.rb index fff6fd46a6..5c2ee14258 100644 --- a/lib/action_cable/connection/base.rb +++ b/lib/action_cable/connection/base.rb @@ -69,7 +69,7 @@ module ActionCable data = ActiveSupport::JSON.decode data - case data['action'] + case data['command'] when 'subscribe' subscribe_channel(data) when 'unsubscribe' diff --git a/lib/assets/javascripts/cable.js.coffee b/lib/assets/javascripts/cable.js.coffee index 345771dd1f..7c033d3b08 100644 --- a/lib/assets/javascripts/cable.js.coffee +++ b/lib/assets/javascripts/cable.js.coffee @@ -28,7 +28,7 @@ class @Cable sendData: (identifier, data) => if @isConnected() - @connection.send JSON.stringify { action: 'message', identifier: identifier, data: data } + @connection.send JSON.stringify { command: 'message', identifier: identifier, data: data } receiveData: (message) => data = JSON.parse message.data @@ -109,11 +109,11 @@ class @Cable subscribeOnServer: (identifier) => if @isConnected() - @connection.send JSON.stringify { action: 'subscribe', identifier: identifier } + @connection.send JSON.stringify { command: 'subscribe', identifier: identifier } unsubscribeOnServer: (identifier) => if @isConnected() - @connection.send JSON.stringify { action: 'unsubscribe', identifier: identifier } + @connection.send JSON.stringify { command: 'unsubscribe', identifier: identifier } pingReceived: (timestamp) => if @lastPingTime? and (timestamp - @lastPingTime) > @PING_STALE_INTERVAL diff --git a/test/server_test.rb b/test/server_test.rb index 50a95b9d59..824875bb99 100644 --- a/test/server_test.rb +++ b/test/server_test.rb @@ -27,7 +27,7 @@ class ServerTest < ActionCableTest puts message.inspect end - ws.send action: 'subscribe', identifier: { channel: 'chat'}.to_json + ws.send command: 'subscribe', identifier: { channel: 'chat'}.to_json end test "subscribing to a channel with invalid params" do |