class Serf::Client::IO
Public Class Methods
new(socket, handler)
click to toggle source
# File lib/serf/client/io.rb, line 10 def initialize socket, handler @socket = socket @handler = handler @up = MessagePack::Unpacker.new(@socket) async.write async.read end
Public Instance Methods
read()
click to toggle source
# File lib/serf/client/io.rb, line 18 def read loop do debug 'IO#read' msg = @up.read @handler.mailbox << msg end end
write()
click to toggle source
# File lib/serf/client/io.rb, line 26 def write loop do debug 'IO#write' header, param = receive debug "writing #{header}" buff = MessagePack::Buffer.new buff << header.to_msgpack if param buff << param.to_msgpack end @socket.write buff.to_str end end