diff --git a/lib/houston/client.rb b/lib/houston/client.rb index a83c536..381b4eb 100644 --- a/lib/houston/client.rb +++ b/lib/houston/client.rb @@ -36,7 +36,6 @@ def push(*notifications) return if notifications.empty? notifications.flatten! - error = nil Connection.open(@gateway_uri, @certificate, @passphrase) do |connection| ssl = connection.ssl @@ -51,32 +50,16 @@ def push(*notifications) connection.write(notification.message) notification.mark_as_sent! - break if notifications.count == 1 || notification == notifications.last - read_socket, write_socket = IO.select([ssl], [ssl], [ssl], nil) if (read_socket && read_socket[0]) - error = connection.read(6) - break - end - end - - return if notifications.count == 1 - - unless error - read_socket, write_socket = IO.select([ssl], nil, [ssl], timeout) - if (read_socket && read_socket[0]) - error = connection.read(6) + if error = connection.read(6) + command, status, index = error.unpack("ccN") + notification.apns_error_code = status + notification.mark_as_unsent! + end end end end - - if error - command, status, index = error.unpack("ccN") - notifications[index].apns_error_code = status - notifications.slice!(0..index) - notifications.each(&:mark_as_unsent!) - push(*notifications) - end end def unregistered_devices