Sha256: 704757e83f7b849f436ab9675f0b21955656e3fb58102805fb0f9ed62bb78012

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

require Options.paths.lib + 'ui/output'
require Options.paths.lib + 'rpc/server/agent'
require Options.paths.lib + 'processes/manager'

class Node < Cuboid::RPC::Server::Agent::Node

    def initialize
        @options = Options.instance

        methods.each do |m|
            next if method( m ).owner != Cuboid::RPC::Server::Agent::Node
            self.class.send :private, m
            self.class.send :public, m
        end

        @server = Cuboid::RPC::Server::Base.new
        @server.add_async_check do |method|
            # methods that expect a block are async
            method.parameters.flatten.include?( :block )
        end
        @server.add_handler( 'node', self )

        super @options, @server

        @server.start
    end

    def url
        @server.url
    end

    def shutdown
        Arachni::Reactor.global.delay 1 do
            Process.kill( 'KILL', Process.pid )
        end
    end

    def connect_to_peer( url )
        self.class.connect_to_peer( url )
    end

    def self.connect_to_peer( url )
        c = Cuboid::RPC::Client::Base.new( url )
        Arachni::RPC::Proxy.new( c, 'node' )
    end
end

Arachni::Reactor.global.run do
    Node.new
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cuboid-0.1.3 spec/support/fixtures/executables/node.rb
cuboid-0.1.2 spec/support/fixtures/executables/node.rb
cuboid-0.1.1 spec/support/fixtures/executables/node.rb
cuboid-0.1.0 spec/support/fixtures/executables/node.rb