class Evesync::IPC::Client

Attributes

ip[R]
uri[R]

Public Class Methods

new(params) click to toggle source
# File lib/evesync/ipc/client.rb, line 12
def initialize(params)
  check_params_provided(params, [:port])
  port = get_port(params)
  @ip = params[:ip] || 'localhost' # TODO: check ip
  @uri = "druby://#{@ip}:#{port}"
  # to remote calls for unmarshallable objects
  DRb.start_service
end

Public Instance Methods

method_missing(method, *args, &block) click to toggle source

TODO: add callbacks

# File lib/evesync/ipc/client.rb, line 22
def method_missing(method, *args, &block)
  Log.debug("RPC Client calling '#{method}' on #{@uri}")
  # FIXME: don't send +start+ and +stop+ and +initialize+
  begin
    service = DRbObject.new_with_uri(@uri)
    res = service.send(method, *args, &block)
    Log.debug("RPC Client method '#{method}' handled on #{@uri}")
    res
  rescue StandardError
    Log.warn("RPC Client ERROR: no connection")
    nil
  end
end