Sha256: 8c768349e52291b8ca03d3555cdf95a7a35f4c839be4622c0e72ed90beed31a7

Contents?: true

Size: 644 Bytes

Versions: 2

Compression:

Stored size: 644 Bytes

Contents

# frozen_string_literal: true

require "pakyow/support/message_verifier"

require "pakyow/realtime/websocket"

module Pakyow
  module Realtime
    module Actions
      class Upgrader
        def call(connection)
          if websocket?(connection)
            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

2 entries across 2 versions & 1 rubygems

Version Path
pakyow-realtime-1.0.0.rc2 lib/pakyow/realtime/actions/upgrader.rb
pakyow-realtime-1.0.0.rc1 lib/pakyow/realtime/actions/upgrader.rb