lib/pigato/client.rb in pigato-0.2.7 vs lib/pigato/client.rb in pigato-0.2.8
- old
+ new
@@ -15,35 +15,35 @@
if @conf[:autostart]
start
end
end
- def request service, request, timeout = @conf[:timeout]
+ def request service, request, opts = {}
return nil if @socket == nil;
- request = [Oj.dump(request)]
+ request = [Oj.dump(request), Oj.dump(opts)]
rid = SecureRandom.uuid
request = [Pigato::C_CLIENT, Pigato::W_REQUEST, service, rid].concat(request)
msg = ZMQ::Message.new
request.reverse.each{|p| msg.push(ZMQ::Frame(p))}
@socket.send_message msg
res = []
while 1 do
- chunk = _recv(rid, timeout)
+ chunk = _recv rid
break if chunk == nil
res << Oj.load(chunk[4])
break if chunk[0] == Pigato::W_REPLY
end
return nil if res.length == 0
return res[0] if res.length == 1
res
end
- def _recv rid, timeout = @timeout
- @socket.rcvtimeo = timeout;
+ def _recv rid
+ @socket.rcvtimeo = @conf[:timeout]
data = []
d1 = Time.now
msg = @socket.recv_message()
while 1 do
break if !msg || msg.size == 0