Class: Ramp::AmpClient
- Inherits:
-
Object
- Object
- Ramp::AmpClient
- Defined in:
- lib/ramp.rb
Overview
AmpClient class is responsble for establishing a connection to a AMP server
Constant Summary collapse
- @@sent_packets =
Hash.new
Instance Method Summary collapse
-
#call(command, kwargs) ⇒ Object
- This method will call the given command on the remote server with given arguments in kwargs command
-
is a subclass of Command class.
-
#initialize(host, port, kwargs = {secure: false, ssl_key: nil, ssl_cert:nil, async: false}) ⇒ AmpClient
constructor
- host
- address of remote amp server port
-
port to connect to.
Constructor Details
#initialize(host, port, kwargs = {secure: false, ssl_key: nil, ssl_cert:nil, async: false}) ⇒ AmpClient
- host
-
address of remote amp server
- port
-
port to connect to.
- kwarrgs
-
is a hash that contains extra optional arguments.
- secure
-
Use an SSL secured connection
- ssl_key
-
Path to SSL key.
- ssl_cert
-
Path to client SSL cert file.
- async
-
If this argument was true then Ramp use a threaded solution to send the request and handle the response
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/ramp.rb', line 97 def initialize (host, port, kwargs={secure: false, ssl_key: nil, ssl_cert:nil, async: false}) @async = kwargs[:async] @secure = kwargs[:secure] @ssl_key = kwargs[:ssl_key] @ssl_cert = kwargs[:ssl_cert] @host = host @port = port make_connection end |
Instance Method Details
#call(command, kwargs) ⇒ Object
This method will call the given command on the remote server with given arguments in kwargs
- command
-
is a subclass of Command class.
- kwargs
-
the arguments for the command’s initilize method.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/ramp.rb', line 118 def call(command, kwargs) # Create a new command instance obj = command.new kwargs # Add the curretn command instance to the sent hash @@sent_packets[obj.ask] = obj if @async t = Thread.new { transfer obj.to_s } t.abort_on_exception = true t.run else transfer obj.to_s end end |