Sha256: 508f6e20e7dd106aa61552c662cc57b1425467ac5918e6f83d8a965c397ca71a

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

require_dependency 'rvt/application_controller'

module RVT
  class ConsoleSessionsController < ApplicationController
    rescue_from ConsoleSession::Unavailable do |exception|
      render json: exception, status: :gone
    end

    rescue_from ConsoleSession::Invalid do |exception|
      render json: exception, status: :unprocessable_entity
    end

    rescue_from ConsoleSession::Unauthorized do |exception|
      render json: exception, status: :unauthorized
    end

    def index
      @console_session = ConsoleSession.create
    end

    def input
      @console_session = ConsoleSession.find_by_pid_and_uid(params[:id], params[:uid])
      @console_session.send_input(console_session_params[:input])

      head :no_content
    end

    def configuration
      @console_session = ConsoleSession.find_by_pid_and_uid(params[:id], params[:uid])
      @console_session.configure(console_session_params)

      head :no_content
    end

    def pending_output
      @console_session = ConsoleSession.find_by_pid_and_uid(params[:id], params[:uid])

      render json: { output: @console_session.pending_output }
    end

    private

    def console_session_params
      params.permit(:id, :uid, :input, :width, :height)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rvt-1.1.0 app/controllers/rvt/console_sessions_controller.rb
rvt-1.0.0 app/controllers/rvt/console_sessions_controller.rb