Method: Net::SSH::Connection::Channel#do_request
- Defined in:
- lib/net/ssh/connection/channel.rb
#do_request(request, want_reply, data) ⇒ Object
Invoked when the server sends a channel request. If any #on_request callback has been registered for the specific type of this request, it is invoked. If want_reply
is true, a packet will be sent of either CHANNEL_SUCCESS or CHANNEL_FAILURE type. If there was no callback to handle the request, CHANNEL_FAILURE will be sent. Otherwise, CHANNEL_SUCCESS, unless the callback raised ChannelRequestFailed. The callback should accept the channel as the first argument, and the request-specific data as the second.
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 |
# File 'lib/net/ssh/connection/channel.rb', line 545 def do_request(request, want_reply, data) #:nodoc: result = true begin callback = @on_request[request] or raise ChannelRequestFailed callback.call(self, data) rescue ChannelRequestFailed result = false end if want_reply msg = Buffer.from(:byte, result ? CHANNEL_SUCCESS : CHANNEL_FAILURE, :long, remote_id) connection.(msg) end end |