Sha256: ff360023840296fdb041b0ed2347dbaa53e3e09bcd86b16f9aaabb16b2ac12f2

Contents?: true

Size: 726 Bytes

Versions: 7

Compression:

Stored size: 726 Bytes

Contents

# frozen_string_literal: true

require "pakyow/support/message_verifier"

require "pakyow/realtime/websocket"

module Pakyow
  class Application
    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
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pakyow-realtime-1.0.6 lib/pakyow/application/actions/realtime/upgrader.rb
pakyow-realtime-1.0.5 lib/pakyow/application/actions/realtime/upgrader.rb
pakyow-realtime-1.0.4 lib/pakyow/application/actions/realtime/upgrader.rb
pakyow-realtime-1.0.3 lib/pakyow/application/actions/realtime/upgrader.rb
pakyow-realtime-1.0.2 lib/pakyow/application/actions/realtime/upgrader.rb
pakyow-realtime-1.0.1 lib/pakyow/application/actions/realtime/upgrader.rb
pakyow-realtime-1.0.0 lib/pakyow/application/actions/realtime/upgrader.rb