Sha256: 54901bbae545df73395a4b878842efe7ee70a11be1e193b0f8a3466e705ebcb3

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

module Cuboid

require Options.paths.lib + 'rpc/client/base'

module RPC
class Client

# RPC Agent client
#
# @author Tasos "Zapotek" Laskos <tasos.laskos@gmail.com>
class Agent
    # Not always available, set by the parent.
    attr_accessor :pid

    attr_reader :node

    def initialize( url, options = nil )
        @client = Base.new( url, nil, options )
        @node   = Arachni::RPC::Proxy.new( @client, 'node' )

        Cuboid::Application.application.agent_services.keys.each do |name|
            self.class.send( :attr_reader, name.to_sym )

            instance_variable_set(
              "@#{name}".to_sym,
              Arachni::RPC::Proxy.new( @client, name )
            )
        end
    end

    def url
        @client.url
    end

    def address
        @client.address
    end

    def port
        @client.port
    end

    def close
        @client.close
    end

    private

    # Used to provide the illusion of locality for remote methods
    def method_missing( sym, *args, &block )
        @client.call( "agent.#{sym.to_s}", *args, &block )
    end

end

end
end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cuboid-0.1.3 lib/cuboid/rpc/client/agent.rb
cuboid-0.1.2 lib/cuboid/rpc/client/agent.rb
cuboid-0.1.1 lib/cuboid/rpc/client/agent.rb
cuboid-0.1.0 lib/cuboid/rpc/client/agent.rb