Class: Cuboid::RPC::Server::Base

Inherits:
Toq::Server
  • Object
show all
Defined in:
lib/cuboid/rpc/server/base.rb

Overview

RPC server class

Author:

Instance Method Summary collapse

Constructor Details

#initialize(options = nil, token = nil) ⇒ Base

Returns a new instance of Base.

Parameters:

  • options (Hash) (defaults to: nil)
  • token (String) (defaults to: nil)

    Optional authentication token.

Options Hash (options):

  • :host (Integer)
  • :port (Integer)
  • :socket (Integer)
  • :ssl_ca (Integer)
  • :ssl_pkey (Integer)
  • :ssl_cert (Integer)


24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cuboid/rpc/server/base.rb', line 24

def initialize( options = nil, token = nil )

    # If given nil use the global defaults.
    options ||= Options.rpc.to_server_options
    @options = options

    super(options.merge(
        serializer: Serializer,
        token:      token
    ))

    return if @reactor.running?
    @reactor.run_in_thread
end

Instance Method Details

#addressObject



39
40
41
# File 'lib/cuboid/rpc/server/base.rb', line 39

def address
    @options[:external_address] || @options[:host]
end

#portObject



43
44
45
# File 'lib/cuboid/rpc/server/base.rb', line 43

def port
    @options[:port]
end

#ready?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/cuboid/rpc/server/base.rb', line 58

def ready?
    @ready ||= false
end

#startObject



53
54
55
56
# File 'lib/cuboid/rpc/server/base.rb', line 53

def start
    super
    @ready = true
end

#urlObject



47
48
49
50
51
# File 'lib/cuboid/rpc/server/base.rb', line 47

def url
    return @options[:socket] if @options[:socket]

    "#{address}:#{port}"
end