Class: Evesync::IPC::Client
- Inherits:
-
Object
- Object
- Evesync::IPC::Client
- Includes:
- Evesync::IPC
- Defined in:
- lib/evesync/ipc/client.rb
Instance Attribute Summary collapse
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(params) ⇒ Client
constructor
A new instance of Client.
-
#method_missing(method, *args, &block) ⇒ Object
TODO: add callbacks.
Constructor Details
#initialize(params) ⇒ Client
Returns a new instance of Client.
12 13 14 15 16 17 18 19 |
# 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 |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
TODO: add callbacks
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# 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 |
Instance Attribute Details
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
10 11 12 |
# File 'lib/evesync/ipc/client.rb', line 10 def ip @ip end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
10 11 12 |
# File 'lib/evesync/ipc/client.rb', line 10 def uri @uri end |