Sha256: 84bec8d468f278aa7bccbabd2e5cf112056994a626dae0e9112014331ced68d6

Contents?: true

Size: 662 Bytes

Versions: 3

Compression:

Stored size: 662 Bytes

Contents

# frozen_string_literal: true

require "pakyow/support/message_verifier"

require "pakyow/realtime/websocket"

module Pakyow
  module Actions
    module Realtime
      class Upgrader
        def call(connection)
          if websocket?(connection)
            Pakyow::Realtime::WebSocket.new(connection.verifier.verify(connection.params[:id]), connection)
            connection.halt
          end
        rescue Support::MessageVerifier::TamperedMessage
          connection.status = 403
          connection.halt
        end

        private

        def websocket?(connection)
          connection.path == "/pw-socket"
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pakyow-realtime-1.0.0.rc5 lib/pakyow/actions/realtime/upgrader.rb
pakyow-realtime-1.0.0.rc4 lib/pakyow/actions/realtime/upgrader.rb
pakyow-realtime-1.0.0.rc3 lib/pakyow/actions/realtime/upgrader.rb