Method: APND::Daemon::Protocol#unbind
- Defined in:
- lib/apnd/daemon/protocol.rb
#unbind ⇒ Object
Called when a client connection is closed
Checks @buffer for any pending notifications to be queued
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/apnd/daemon/protocol.rb', line 23 def unbind # totally broken. @buffer.chomp! while(@buffer.length > 0) do # 3 bytes for header # 32 bytes for token # 2 bytes for json length # taking the last is acceptable because we know it's never # longer than 256 bytes from the apple documentation. json_length = @buffer.slice(35,37).unpack('CC').last chunk = @buffer.slice!(0,json_length + 3 + 32 + 2) if notification = APND::Notification.valid?(chunk) APND.logger "#{@address.last}:#{@address.first} added new Notification to queue" queue.push(notification) else APND.logger "#{@address.last}:#{@address.first} submitted invalid Notification" end @buffer.strip! end APND.logger "#{@address.last}:#{@address.first} closed connection" end |