lib/pigato/client.rb in pigato-0.1.2 vs lib/pigato/client.rb in pigato-0.1.3

- old
+ new

@@ -1,7 +1,8 @@ require "json" require "ffi-rzmq" +require "securerandom" class PigatoClient def initialize broker @broker = broker @@ -13,11 +14,11 @@ end def send service, request, timeout = 2500 request = [request.to_json] - rid = 'RID' + (rand() * 1000000).to_s + rid = SecureRandom.uuid request = [Pigato::C_CLIENT, Pigato::W_REQUEST, service, rid].concat(request) @client.send_strings request res = Array.new res << rid @@ -55,10 +56,10 @@ @poller.deregister @client, ZMQ::DEALER end @client = @context.socket ZMQ::DEALER @client.setsockopt ZMQ::LINGER, 0 - @client.setsockopt ZMQ::IDENTITY, "C" + (rand() * 10).to_s + @client.setsockopt ZMQ::IDENTITY, SecureRandom.uuid @client.connect @broker @poller.register @client, ZMQ::POLLIN end end