Class: EventMachine::JsonRPC::Client::Request

Inherits:
Object
  • Object
show all
Includes:
EM::Deferrable
Defined in:
lib/em-jsonrpc/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client, id) ⇒ Request

Returns a new instance of Request.



163
164
165
166
# File 'lib/em-jsonrpc/client.rb', line 163

def initialize(client, id)
  @client = client
  @id = id
end

Instance Method Details

#deleteObject



168
169
170
# File 'lib/em-jsonrpc/client.rb', line 168

def delete
  @client.pending_requests.delete @id
end

#timeout(seconds) ⇒ Object

Override EM::Deferrable#timeout method so the errback is executed passing a :request_timeout single argument. Also, the request is removed from the list of pending requests.



175
176
177
178
179
180
181
182
# File 'lib/em-jsonrpc/client.rb', line 175

def timeout seconds
  cancel_timeout
  me = self
  @deferred_timeout = EM::Timer.new(seconds) do
    me.delete
    me.fail :request_timeout
  end
end