class IbRubyProxy::Client::Client

A client for interacting with the DRb service

If can be instantiated directly from the DRb service with {.create_drb_ib_client}

It offers the same interface than a {IbRubyProxy::Server::IbClientAdapter} and, also, configures a {CallbacksResponseHandler} so that you can use Ruby blocks to capture callbacks invocations based on the semantics of the invoked methods.

@see CallbacksResponseHandler

Attributes

ib_client[R]

Public Class Methods

create_drb_ib_client(host:, port:) click to toggle source

@private

# File lib/ib_ruby_proxy/client/client.rb, line 33
def self.create_drb_ib_client(host:, port:)
  drb_ib_client = DRbObject.new(nil, "druby://#{host}:#{port}")
  DRb::DRbServer.verbose = true
  DRb.install_id_conv ::DRb::TimerIdConv.new 60
  DRb.start_service
  drb_ib_client
end
from_drb(host: 'localhost', port: 1992) click to toggle source

@return [Client] @param [String] host DRb host localhost by default @param [Object] port DRb port 1992 by default

# File lib/ib_ruby_proxy/client/client.rb, line 20
def self.from_drb(host: 'localhost', port: 1992)
  new(create_drb_ib_client(host: host, port: port))
end
new(ib_client) click to toggle source

@param [IbRubyProxy::Server::IbClientAdapter] ib_client

# File lib/ib_ruby_proxy/client/client.rb, line 25
def initialize(ib_client)
  @ib_client = ib_client
  @promises_by_request_id = {}
  @callbacks_response_handler = CallbacksResponseHandler.for_ib
  @ib_client.add_ib_callbacks_observer ResponseHandleObserver.new(@callbacks_response_handler)
end

Private Instance Methods

method_missing(method, *arguments, &block) click to toggle source
# File lib/ib_ruby_proxy/client/client.rb, line 47
def method_missing(method, *arguments, &block)
  @ib_client.public_send(method, *arguments, &block)
  @callbacks_response_handler.method_invoked method, *arguments, &block
end
respond_to_missing?(name, include_private = false) click to toggle source
# File lib/ib_ruby_proxy/client/client.rb, line 43
def respond_to_missing?(name, include_private = false)
  @ib_client.respond_to?(name, include_private)
end