diff options
-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 |