diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2015-03-25 13:23:34 -0500 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2015-03-25 13:23:34 -0500 |
commit | 432139183e885f69c6a8f576af7a178842a6e2a1 (patch) | |
tree | d0cdfbe80cf630392d5fc868b8ffc92d2da39282 /lib | |
parent | e570864c1f30c1b3e8b75c0039d981ccfccba08d (diff) | |
download | rails-432139183e885f69c6a8f576af7a178842a6e2a1.tar.gz rails-432139183e885f69c6a8f576af7a178842a6e2a1.tar.bz2 rails-432139183e885f69c6a8f576af7a178842a6e2a1.zip |
Dont process messages when the websocket is no longer open
Diffstat (limited to 'lib')
-rw-r--r-- | lib/action_cable/server.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/action_cable/server.rb b/lib/action_cable/server.rb index b6bceda81b..77010071d2 100644 --- a/lib/action_cable/server.rb +++ b/lib/action_cable/server.rb @@ -70,6 +70,8 @@ module ActionCable end def received_data(data) + return unless websocket_alive? + data = ActiveSupport::JSON.decode data case data['action'] @@ -141,5 +143,9 @@ module ActionCable [404, {'Content-Type' => 'text/plain'}, ['Page not found']] end + def websocket_alive? + @websocket && @websocket.ready_state == Faye::WebSocket::API::OPEN + end + end end |