lib/racoon/apns/connection.rb in racoon-0.6.0 vs lib/racoon/apns/connection.rb in racoon-1.0.0

- old
+ new

@@ -34,19 +34,34 @@ @sock.close @ssl = nil @sock = nil end + def read + errors ||= [] + while error = @ssl.read(6) + errors << parse_tuple(error) + end + errors + end + def write(bytes) if host.include? "sandbox" notification = Notification.parse(bytes) Config.logger.debug "#{Time.now} [#{host}:#{port}] Device: #{notification.device_token.unpack('H*')} sending #{notification.json_payload}" end @ssl.write(notification.to_bytes) end def connected? @ssl + end + + private + + def parse_tuple(data) + packet = data.unpack("c1c1N1") + { :command => packet[0], :status => packet[1], :identifier => packet[2] } end end end end