Sha256: b3fe47591811b2be044f206007837c7b6e9c7f57d9b8baa2fc2c5d45729ff33e

Contents?: true

Size: 878 Bytes

Versions: 3

Compression:

Stored size: 878 Bytes

Contents

require 'spider-gazelle/upgrades/websocket'


module Orchestrator
    class PersistenceController < ApiController
        CONTROL = Control.instance


        # Supply a bearer_token param for oauth
        def websocket
            hijack = request.env['rack.hijack']
            if hijack && CONTROL.ready
                promise = hijack.call

                # grab user for authorization checks in the web socket
                user = current_user
                promise.then do |hijacked|
                    ws = ::SpiderGazelle::Websocket.new(hijacked.socket, hijacked.env)
                    WebsocketManager.new(ws, user)
                    ws.start
                end

                throw :async     # to prevent rails from complaining 
            else
                render nothing: true, status: :method_not_allowed
            end
        end
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
orchestrator-1.0.3 app/controllers/orchestrator/persistence_controller.rb
orchestrator-1.0.2 app/controllers/orchestrator/persistence_controller.rb
orchestrator-1.0.1 app/controllers/orchestrator/persistence_controller.rb