Class: EM::RemoteCall::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/em_remote_call/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Client

Returns a new instance of Client.



73
74
75
76
77
78
79
# File 'lib/em_remote_call/client.rb', line 73

def initialize(opts)
  @name               = opts[:name] ||= :default
  @remote_class_name  = opts[:remote_class_name]
  @socket             = opts[:socket]
  @port               = opts[:port]
  @instance_finder    = opts[:instance_finder] ||= :id
end

Instance Attribute Details

#instance_finderObject (readonly)

Returns the value of attribute instance_finder.



70
71
72
# File 'lib/em_remote_call/client.rb', line 70

def instance_finder
  @instance_finder
end

#nameObject (readonly)

Returns the value of attribute name.



70
71
72
# File 'lib/em_remote_call/client.rb', line 70

def name
  @name
end

#remote_class_nameObject (readonly)

Returns the value of attribute remote_class_name.



70
71
72
# File 'lib/em_remote_call/client.rb', line 70

def remote_class_name
  @remote_class_name
end

Instance Method Details

#call(call) ⇒ Object



81
82
83
84
85
86
87
# File 'lib/em_remote_call/client.rb', line 81

def call(call)
  unless @connection && @connection.connected?
    @connection = EM::RemoteCall::ClientConnection.connect_to *[@socket, @port].compact
  end
  
  @connection.send_data call
end