Class: Etherlite::Connection
- Inherits:
-
Object
- Object
- Etherlite::Connection
- Defined in:
- lib/etherlite/connection.rb
Instance Method Summary collapse
-
#initialize(_uri) ⇒ Connection
constructor
A new instance of Connection.
- #ipc_call(_method, *_params) ⇒ Object
Constructor Details
#initialize(_uri) ⇒ Connection
Returns a new instance of Connection.
3 4 5 |
# File 'lib/etherlite/connection.rb', line 3 def initialize(_uri) @uri = _uri end |
Instance Method Details
#ipc_call(_method, *_params) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/etherlite/connection.rb', line 7 def ipc_call(_method, *_params) id = new_unique_id payload = { jsonrpc: "2.0", method: _method, params: _params, id: id } # TODO: support ipc Net::HTTP.start(@uri.hostname, @uri.port) do |http| return handle_response http.post( @uri.path.empty? ? '/' : @uri.path, payload.to_json, "Content-Type" => "application/json" ), id end end |