Class: OWNet::Response
- Inherits:
-
Object
- Object
- OWNet::Response
- Defined in:
- lib/connection.rb
Overview
Encapsulates a response from owserver
Constant Summary collapse
- PING_PAYLOAD =
Minus one interpreted as an unsigned int
4294967295
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#return_value ⇒ Object
Returns the value of attribute return_value.
Instance Method Summary collapse
-
#initialize(socket) ⇒ Response
constructor
A new instance of Response.
- #isping? ⇒ Boolean
Constructor Details
#initialize(socket) ⇒ Response
Returns a new instance of Response.
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/connection.rb', line 73 def initialize(socket) data = socket.read(24) raise ShortRead if !data || data.size != 24 version, @payload_len, self.return_value, @format_flags, @data_len, @offset = data.unpack('NNNNNN') if @payload_len > 0 && !isping? #FIXME: Guard against a short read here @data = socket.read(@payload_len)[@offset..@data_len+@offset-1] end end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
71 72 73 |
# File 'lib/connection.rb', line 71 def data @data end |
#return_value ⇒ Object
Returns the value of attribute return_value.
71 72 73 |
# File 'lib/connection.rb', line 71 def return_value @return_value end |
Instance Method Details
#isping? ⇒ Boolean
86 87 88 |
# File 'lib/connection.rb', line 86 def isping? @payload_len == PING_PAYLOAD end |