lib/pigato/base.rb in pigato-0.4.2 vs lib/pigato/base.rb in pigato-0.4.3

- old
+ new

@@ -1,10 +1,12 @@ class Pigato::Base @@sockets = {} + @@sockets_ids = {} @@mtxs = {} @@mtx = Mutex.new + @@global_heartbeat_at = Time.now def init @iid = SecureRandom.uuid end @@ -47,18 +49,20 @@ ctx = ZMQ::Context.new ctx.linger = 0 end socket = ctx.socket ZMQ::DEALER - socket.identity = SecureRandom.uuid + sid = SecureRandom.uuid + socket.identity = sid socket.connect @broker if !@conf[:timeout].nil? then - socket.rcvtimeo = @conf[:timeout]; + socket.rcvtimeo = @conf[:timeout] end @@sockets[get_iid] = socket + @@sockets_ids[get_iid] = sid } end def sock_close @@mtx.synchronize { @@ -71,9 +75,10 @@ begin socket.close rescue end @@sockets.delete(iid) + @@sockets_ids.delete(iid) end } end def start