diff options
-rw-r--r-- | lib/action_cable/connection/base.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/action_cable/connection/base.rb b/lib/action_cable/connection/base.rb index c3c99dcec4..4bc6a14aaa 100644 --- a/lib/action_cable/connection/base.rb +++ b/lib/action_cable/connection/base.rb @@ -53,7 +53,7 @@ module ActionCable def receive(data_in_json) if websocket_alive? - data = ActiveSupport::JSON.decode data_in_json + data = decode_json data_in_json case data['command'] when 'subscribe' then subscriptions.add data @@ -123,13 +123,17 @@ module ActionCable def process_message(message) - subscriptions.find(message['identifier']).perform_action(ActiveSupport::JSON.decode(message['data'])) + subscriptions.find(message['identifier']).perform_action decode_json(message['data']) rescue Exception => e logger.error "Could not process message (#{message.inspect})" log_exception(e) end + def decode_json(json) + ActiveSupport::JSON.decode json + end + def respond_to_invalid_request [ 404, { 'Content-Type' => 'text/plain' }, [ 'Page not found' ] ] end |