Class: AppleShove::APNS::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/apple_shove/apns/connection.rb

Direct Known Subclasses

FeedbackConnection, NotifyConnection

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port, p12_string) ⇒ Connection

Returns a new instance of Connection.



9
10
11
12
13
14
15
# File 'lib/apple_shove/apns/connection.rb', line 9

def initialize(host, port, p12_string)
  @host       = host
  @port       = port
  @p12_string = p12_string

  @p12        = nil
end

Instance Attribute Details

#last_usedObject (readonly)

Returns the value of attribute last_used.



7
8
9
# File 'lib/apple_shove/apns/connection.rb', line 7

def last_used
  @last_used
end

Instance Method Details

#disconnectObject



23
24
25
26
27
28
29
30
31
# File 'lib/apple_shove/apns/connection.rb', line 23

def disconnect
  @ssl_sock.close if @ssl_sock

  begin
    @sock.close if @sock
  rescue IOError
    @sock = nil
  end
end

#reconnectObject



33
34
35
36
# File 'lib/apple_shove/apns/connection.rb', line 33

def reconnect
  disconnect
  connect
end

#safe_last_usedObject



38
39
40
# File 'lib/apple_shove/apns/connection.rb', line 38

def safe_last_used
  @last_used || Time.at(0)
end

#socketObject

lazy connect the socket



18
19
20
21
# File 'lib/apple_shove/apns/connection.rb', line 18

def socket
  connect unless connected?
  @ssl_sock
end