Class: EM::APNS::Connection

Inherits:
Connection
  • Object
show all
Defined in:
lib/em-apns/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#numObject

Returns the value of attribute num.


3
4
5
# File 'lib/em-apns/connection.rb', line 3

def num
  @num
end

Instance Method Details

#connection_completedObject

[View source]

13
14
15
# File 'lib/em-apns/connection.rb', line 13

def connection_completed
  EM::APNS.logger.info("Connection established")
end

#on_unbind(&block) ⇒ Object

[View source]

28
29
30
# File 'lib/em-apns/connection.rb', line 28

def on_unbind &block
  @unbind = block
end

#post_initObject

[View source]

5
6
7
8
9
10
11
# File 'lib/em-apns/connection.rb', line 5

def post_init
  start_tls(
    :private_key_file => EM::APNS.key,
    :cert_chain_file  => EM::APNS.cert,
    :verify_peer      => false
  )
end

#receive_data(data) ⇒ Object

[View source]

17
18
19
20
21
# File 'lib/em-apns/connection.rb', line 17

def receive_data(data)
  data_array = data.unpack("ccN")
  error_response = Error.new(*data_array)
  EM::APNS.logger.info("#{error_response}")
end

#unbindObject

[View source]

23
24
25
26
# File 'lib/em-apns/connection.rb', line 23

def unbind
  EM::APNS.logger.info("Connection terminated")
  @unbind.call(self) if @unbind
end