Class: Response
- Inherits:
-
Object
- Object
- Response
- Defined in:
- lib/libowl/response.rb
Overview
Response of a client request to the world model
Instance Method Summary collapse
-
#cancel ⇒ Object
Cancel this request.
-
#get ⇒ Object
Get the data of this Response, blocking until that data is ready or an error occurs.
-
#getError ⇒ Object
Get the error that occured.
-
#initialize(cwc, key) ⇒ Response
constructor
Initialize with the ClientWorldConnection that spawed this Response and the key of the request.
-
#isError ⇒ Object
Returns true if an error has occured.
-
#ready ⇒ Object
Returns true if data is available for a call to get().
Constructor Details
#initialize(cwc, key) ⇒ Response
Initialize with the ClientWorldConnection that spawed this Response and the key of the request.
30 31 32 33 |
# File 'lib/libowl/response.rb', line 30 def initialize(cwc, key) @cwc = cwc @request_key = key end |
Instance Method Details
#cancel ⇒ Object
Cancel this request.
69 70 71 |
# File 'lib/libowl/response.rb', line 69 def cancel() return @cwc.cancelRequest(@request_key) end |
#get ⇒ Object
Get the data of this Response, blocking until that data is ready or an error occurs.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/libowl/response.rb', line 38 def get() while (not (ready() or isError())) sleep(1) end if (isError()) raise getError() else return @cwc.getNext(@request_key) end end |
#getError ⇒ Object
Get the error that occured.
63 64 65 |
# File 'lib/libowl/response.rb', line 63 def getError() return @cwc.getError(@request_key) end |
#isError ⇒ Object
Returns true if an error has occured.
57 58 59 |
# File 'lib/libowl/response.rb', line 57 def isError() return @cwc.hasError(@request_key) end |
#ready ⇒ Object
Returns true if data is available for a call to get().
51 52 53 |
# File 'lib/libowl/response.rb', line 51 def ready() return @cwc.hasNext(@request_key) end |