Module: APND::Daemon::Protocol
- Included in:
- ServerConnection
- Defined in:
- lib/apnd/daemon/protocol.rb
Overview
Daemon::Protocol handles incoming APNs
Instance Method Summary collapse
-
#post_init ⇒ Object
Called when a client connection is opened.
-
#receive_data(data) ⇒ Object
Add incoming notification(s) to the queue.
-
#unbind ⇒ Object
Called when a client connection is closed.
Instance Method Details
#post_init ⇒ Object
Called when a client connection is opened
12 13 14 15 |
# File 'lib/apnd/daemon/protocol.rb', line 12 def post_init @address = ::Socket.unpack_sockaddr_in(self.get_peername) APND.ohai "#{@address.last}:#{@address.first} opened connection" end |
#receive_data(data) ⇒ Object
Add incoming notification(s) to the queue
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/apnd/daemon/protocol.rb', line 27 def receive_data(data) (@buffer ||= "") << data @buffer.each_line do |line| if notification = APND::Notification.valid?(line) APND.ohai "#{@address.last}:#{@address.first} added new Notification to queue" queue.push(notification) else APND.ohai "#{@address.last}:#{@address.first} submitted invalid Notification" end end end |
#unbind ⇒ Object
Called when a client connection is closed
20 21 22 |
# File 'lib/apnd/daemon/protocol.rb', line 20 def unbind APND.ohai "#{@address.last}:#{@address.first} closed connection" end |