Class: StepResponse

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

Overview

Incrementeal response of a client streaming request to the world model

Instance Method Summary collapse

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

#cancelObject

Cancel the streaming request.



76
77
78
# File 'lib/libowl/step_response.rb', line 76

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

#getErrorObject

Get the error that occured.



64
65
66
# File 'lib/libowl/step_response.rb', line 64

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

#hasNextObject

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

#isCompleteObject

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

#isErrorObject

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

#nextObject

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