Class: StepResponse
- Inherits:
-
Object
- Object
- StepResponse
- Defined in:
- lib/libowl/step_response.rb
Overview
Incrementeal response of a client streaming request to the world model
Instance Method Summary collapse
-
#cancel ⇒ Object
Cancel the streaming request.
-
#getError ⇒ Object
Get the error that occured.
-
#hasNext ⇒ Object
Returns true if data is available for a call to next().
-
#initialize(cwc, key) ⇒ StepResponse
constructor
Initialize with the ClientWorldConnection that spawed this Response and the key of the request.
-
#isComplete ⇒ Object
True if this streaming request will have no more data.
-
#isError ⇒ Object
Returns true if an error has occured.
-
#next ⇒ Object
Get the data of this StepResponse, blocking until that data is ready or an error occurs.
Constructor Details
#initialize(cwc, key) ⇒ StepResponse
Initialize with the ClientWorldConnection that spawed this Response and the key of the request.
31 32 33 34 |
# File 'lib/libowl/step_response.rb', line 31 def initialize(cwc, key) @cwc = cwc @request_key = key end |
Instance Method Details
#cancel ⇒ Object
Cancel the streaming request.
76 77 78 |
# File 'lib/libowl/step_response.rb', line 76 def cancel() return @cwc.cancelRequest(@request_key) end |
#getError ⇒ Object
Get the error that occured.
64 65 66 |
# File 'lib/libowl/step_response.rb', line 64 def getError() return @cwc.getError(@request_key) end |
#hasNext ⇒ Object
Returns true if data is available for a call to next().
52 53 54 |
# File 'lib/libowl/step_response.rb', line 52 def hasNext() return @cwc.hasNext(@request_key) end |
#isComplete ⇒ Object
True if this streaming request will have no more data.
70 71 72 |
# File 'lib/libowl/step_response.rb', line 70 def isComplete() return @cwc.isComplete(@request_key) end |
#isError ⇒ Object
Returns true if an error has occured.
58 59 60 |
# File 'lib/libowl/step_response.rb', line 58 def isError() return @cwc.hasError(@request_key) end |
#next ⇒ Object
Get the data of this StepResponse, blocking until that data is ready or an error occurs.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/libowl/step_response.rb', line 39 def next() while (not (hasNext() or isError())) sleep(1) end if (isError()) raise getError() else return @cwc.getNext(@request_key) end end |