Module: ApnServer::Protocol

Included in:
ServerConnection
Defined in:
lib/apnserver/protocol.rb

Instance Method Summary collapse

Instance Method Details

#post_initObject



3
4
5
6
# File 'lib/apnserver/protocol.rb', line 3

def post_init
  @address = Socket.unpack_sockaddr_in(self.get_peername)
  Config.logger.debug "#{Time.now} [#{address.last}:#{address.first}] CONNECT"
end

#receive_data(data) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/apnserver/protocol.rb', line 12

def receive_data(data)
  (@buf ||= "") << data
  if notification = ApnServer::Notification.valid?(@buf)
    Config.logger.debug "#{Time.now} [#{address.last}:#{address.first}] found valid Notification: #{notification}"
    queue.push(notification)
  else
    Config.logger.debug "#{Time.now} [#{address.last}:#{address.first}] invalid notification: #{@buf}"
  end
end

#unbindObject



8
9
10
# File 'lib/apnserver/protocol.rb', line 8

def unbind
  Config.logger.debug "#{Time.now} [#{address.last}:#{address.first}] DISCONNECT"
end