Class: DpStmMap::SocketTransport

Inherits:
Object
  • Object
show all
Defined in:
lib/dp_stm_map/Manager.rb

Instance Method Summary collapse

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

#closeObject



277
278
279
# File 'lib/dp_stm_map/Manager.rb', line 277

def close
  @socket.close
end

#next_messageObject



264
265
266
267
# File 'lib/dp_stm_map/Manager.rb', line 264

def next_message
  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 send_message msg

  data=msg.serialize
  @socket.write([data.bytesize].pack("Q>"))
  @socket.write(data)
  @socket.flush
end