Class: Muxr::Dispatcher
- Inherits:
-
Object
- Object
- Muxr::Dispatcher
- Defined in:
- lib/muxr/control_server.rb
Overview
Dispatcher dispatches a single JSON-RPC method name to one of the Application’s read/mutate operations. Read-only methods land here in step 2; mutating methods (pane.send_input, layout.set, …) and the asynchronous pane.run / pane.subscribe land in step 3.
Defined Under Namespace
Classes: Error
Constant Summary collapse
- BRACKET_PASTE_START =
"\e[200~".b
- BRACKET_PASTE_END =
"\e[201~".b
- DEFAULT_IDLE_MS =
500- DEFAULT_TIMEOUT_MS =
30_000- MAX_TIMEOUT_MS =
5 min cap so a runaway wait can’t hold a slot forever.
5 * 60 * 1000
Instance Method Summary collapse
- #call(method:, params:, client_io:, request_id:) ⇒ Object
-
#initialize(app, server) ⇒ Dispatcher
constructor
A new instance of Dispatcher.
Constructor Details
#initialize(app, server) ⇒ Dispatcher
Returns a new instance of Dispatcher.
323 324 325 326 |
# File 'lib/muxr/control_server.rb', line 323 def initialize(app, server) @app = app @server = server end |
Instance Method Details
#call(method:, params:, client_io:, request_id:) ⇒ Object
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
# File 'lib/muxr/control_server.rb', line 335 def call(method:, params:, client_io:, request_id:) case method when "ping" then { "pong" => true } when "session.get" then session_get when "session.save" then session_save when "panes.list" then panes_list when "pane.read" then pane_read(params) when "pane.send_input" then pane_send_input(params) when "pane.focus" then pane_focus(params) when "pane.new" then pane_new(params) when "pane.kill" then pane_kill(params) when "pane.promote" then pane_promote(params) when "pane.run" then pane_run(params, client_io, request_id) when "pane.subscribe" then pane_subscribe(params, client_io) when "pane.unsubscribe" then pane_unsubscribe(params, client_io) when "layout.set" then layout_set(params) when "layout.cycle" then layout_cycle when "drawer.toggle" then drawer_action(:toggle_drawer) when "drawer.show" then drawer_action(:show_drawer) when "drawer.hide" then drawer_action(:hide_drawer) when "drawer.reset" then drawer_action(:reset_drawer) when "drawer.send_input" then drawer_send_input(params) when "drawer.read" then drawer_read(params) else raise Error.new("unknown method: #{method}", code: ControlServer::METHOD_NOT_FOUND) end end |