Class: Response

Inherits:
Object
  • Object
show all
Defined in:
lib/libowl/response.rb

Overview

Response of a client request to the world model

Instance Method Summary collapse

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

#cancelObject

Cancel this request.



69
70
71
# File 'lib/libowl/response.rb', line 69

def cancel()
  return @cwc.cancelRequest(@request_key)
end

#getObject

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

#getErrorObject

Get the error that occured.



63
64
65
# File 'lib/libowl/response.rb', line 63

def getError()
  return @cwc.getError(@request_key)
end

#isErrorObject

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

#readyObject

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