Sha256: df699a28405b328891b9c7307206dc7da8c30246a7300c3f6889df8fcebe5fee

Contents?: true

Size: 1.14 KB

Versions: 22

Compression:

Stored size: 1.14 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
        Raktr.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 )
        Toq::Proxy.new( c, 'node' )
    end
end

Raktr.global.run do
    Node.new
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
cuboid-0.2.11 spec/support/fixtures/executables/node.rb
cuboid-0.2.10 spec/support/fixtures/executables/node.rb
cuboid-0.2.9 spec/support/fixtures/executables/node.rb
cuboid-0.2.8 spec/support/fixtures/executables/node.rb
cuboid-0.2.7 spec/support/fixtures/executables/node.rb
cuboid-0.2.6 spec/support/fixtures/executables/node.rb
cuboid-0.2.5 spec/support/fixtures/executables/node.rb
cuboid-0.2.4.2 spec/support/fixtures/executables/node.rb
cuboid-0.2.4.1 spec/support/fixtures/executables/node.rb
cuboid-0.2.4 spec/support/fixtures/executables/node.rb
cuboid-0.2.3 spec/support/fixtures/executables/node.rb
cuboid-0.2.2 spec/support/fixtures/executables/node.rb
cuboid-0.2.1 spec/support/fixtures/executables/node.rb
cuboid-0.2 spec/support/fixtures/executables/node.rb
cuboid-0.1.9.1 spec/support/fixtures/executables/node.rb
cuboid-0.1.9 spec/support/fixtures/executables/node.rb
cuboid-0.1.8 spec/support/fixtures/executables/node.rb
cuboid-0.1.7 spec/support/fixtures/executables/node.rb
cuboid-0.1.6.1 spec/support/fixtures/executables/node.rb
cuboid-0.1.6 spec/support/fixtures/executables/node.rb