lib/kafkr/message_broker.rb in kafkr-0.13.0 vs lib/kafkr/message_broker.rb in kafkr-0.18.0
- old
+ new
@@ -11,23 +11,25 @@
@subscribers << socket
@last_sent[socket] = nil
end
def broadcast(message)
- Kafkr.log message
-
- encrypted_message = Kafkr::Encryptor.new.encrypt(message)
-
+ encrypted_message = Kafkr::Encryptor.new.encrypt(message)
@subscribers.each do |subscriber|
if !subscriber.closed?
subscriber.puts(encrypted_message)
@last_sent[subscriber] = encrypted_message
end
rescue Errno::EPIPE
# Optionally, handle broken pipe error
rescue IOError
- @subscribers.delete(subscriber)
- @last_sent.delete(subscriber)
+ begin
+ @subscribers.delete(subscriber)
+ @last_sent.delete(subscriber)
+ rescue
+ puts "clean up subscribers"
+ end
+
end
end
end
end