Class: Net::SSH::Multi::ChannelProxy

### Home Classes Methods

### In Files

- lib/net/ssh/multi/channel_proxy.rb

### Parent

Object

### Methods

- ::new
- #delegate_to
- #method_missing

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- Net
- Net::SSH
- Net::SSH::Multi
- Net::SSH::Multi::Channel
- Net::SSH::Multi::ChannelProxy
- Net::SSH::Multi::DynamicServer
- Net::SSH::Multi::PendingConnection
- Net::SSH::Multi::Server
- Net::SSH::Multi::ServerList
- Net::SSH::Multi::Session
- Net::SSH::Multi::SessionActions
- Net::SSH::Multi::Subsession
- Net::SSH::Multi::Version

No matching classes.

# Net::SSH::Multi::ChannelProxy

The ChannelProxy is a delegate class that represents a channel that has not yet been opened. It is only used when Net::SSH::Multi is running with with a concurrent connections limit (see Net::SSH::Multi::Session#concurrent_connections).

You'll never need to instantiate one of these directly, and will probably (if all goes well!) never even notice when one of these is in use. Essentially, it is spawned by a Net::SSH::Multi::PendingConnection when the pending connection is asked to open a channel. Any actions performed on the channel proxy will then be recorded, until a real channel is set as the delegate (see delegate_to). At that point, all recorded actions will be replayed on the channel, and any subsequent actions will be immediately delegated to the channel.

### Attributes

on_confirm[R]

This is the "on confirm" callback that gets called when the real channel is opened.

### Public Class Methods

new(&on_confirm) click to toggle source

Instantiates a new channel proxy with the given `on_confirm` callback.

    # File lib/net/ssh/multi/channel_proxy.rb, line 21
    def initialize(&on_confirm)
      @on_confirm = on_confirm
      @recordings = []
      @channel = nil
    end

### Public Instance Methods

delegate_to(channel) click to toggle source

Instructs the proxy to delegate all further actions to the given `channel` (which must be an instance of Net::SSH::Connection::Channel). All recorded actions are immediately replayed, in order, against the delegate channel.

    # File lib/net/ssh/multi/channel_proxy.rb, line 30
    def delegate_to(channel)
      @channel = channel
      @recordings.each do |sym, args, block|
        @channel.__send__(sym, *args, &block)
      end
    end

method_missing(sym, *args, &block) click to toggle source

If a channel delegate has been specified (see delegate_to), the method will be immediately sent to the delegate. Otherwise, the call is added to the list of recorded method calls, to be played back when a delegate is specified.

    # File lib/net/ssh/multi/channel_proxy.rb, line 41
    def method_missing(sym, *args, &block)
      if @channel
        @channel.__send__(sym, *args, &block)
      else
        @recordings << [sym, args, block]
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.