From 432139183e885f69c6a8f576af7a178842a6e2a1 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Wed, 25 Mar 2015 13:23:34 -0500 Subject: Dont process messages when the websocket is no longer open --- lib/action_cable/server.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/action_cable') 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 -- cgit v1.2.3