Class: DpStmMap::SocketTransport
- Inherits:
-
Object
- Object
- DpStmMap::SocketTransport
- Defined in:
- lib/dp_stm_map/Manager.rb
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(socket) ⇒ SocketTransport
constructor
A new instance of SocketTransport.
- #next_message ⇒ Object
- #send_message(msg) ⇒ Object
Constructor Details
#initialize(socket) ⇒ SocketTransport
Returns a new instance of SocketTransport.
260 261 262 |
# File 'lib/dp_stm_map/Manager.rb', line 260 def initialize socket @socket=socket end |
Instance Method Details
#close ⇒ Object
277 278 279 |
# File 'lib/dp_stm_map/Manager.rb', line 277 def close @socket.close end |
#next_message ⇒ Object
264 265 266 267 |
# File 'lib/dp_stm_map/Manager.rb', line 264 def length=@socket.read(8).unpack("Q>")[0] JsonMessage::deserialize(@socket.read(length)) end |
#send_message(msg) ⇒ Object
269 270 271 272 273 274 275 |
# File 'lib/dp_stm_map/Manager.rb', line 269 def msg data=msg.serialize @socket.write([data.bytesize].pack("Q>")) @socket.write(data) @socket.flush end |