Class: Orchestrator::PersistenceController

Inherits:
ApiController
  • Object
show all
Defined in:
app/controllers/orchestrator/persistence_controller.rb

Constant Summary collapse

CONTROL =
Control.instance

Instance Method Summary collapse

Methods inherited from Base

#options

Instance Method Details

#websocketObject

Supply a bearer_token param for oauth



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/orchestrator/persistence_controller.rb', line 10

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