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

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

Overview

RPC server class

Author:

  • Tasos “Zapotek” Laskos <tasos.laskos@gmail.com>

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
# 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
    ))
end

Instance Method Details

#addressObject



36
37
38
# File 'lib/cuboid/rpc/server/base.rb', line 36

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

#portObject



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

def port
    @options[:port]
end

#ready?Boolean

Returns:

  • (Boolean)


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

def ready?
    @ready ||= false
end

#startObject



50
51
52
53
# File 'lib/cuboid/rpc/server/base.rb', line 50

def start
    super
    @ready = true
end

#urlObject



44
45
46
47
48
# File 'lib/cuboid/rpc/server/base.rb', line 44

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

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