Class: ApnsKit::Connection

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, certificate) ⇒ Connection

Returns a new instance of Connection.



16
17
18
19
20
21
# File 'lib/apns_kit/connection.rb', line 16

def initialize(uri, certificate)
    @uri = uri
    @certificate = certificate
    @connected = false
    @mutex = Mutex.new
end

Instance Attribute Details

#connectedObject (readonly)

Returns the value of attribute connected.



10
11
12
# File 'lib/apns_kit/connection.rb', line 10

def connected
  @connected
end

#httpObject (readonly)

Returns the value of attribute http.



14
15
16
# File 'lib/apns_kit/connection.rb', line 14

def http
  @http
end

#uriObject (readonly)

Returns the value of attribute uri.



12
13
14
# File 'lib/apns_kit/connection.rb', line 12

def uri
  @uri
end

Instance Method Details

#closeObject



29
30
31
# File 'lib/apns_kit/connection.rb', line 29

def close
    shutdown if !@thread.nil?
end

#openObject



23
24
25
26
27
# File 'lib/apns_kit/connection.rb', line 23

def open
    if !connected && (@thread.nil? || @thread.stop?)
        start
    end
end

#pingObject



33
34
35
36
37
38
# File 'lib/apns_kit/connection.rb', line 33

def ping
    if @http
        ApnsKit.log_debug("Sending ping")
        @http.ping("whatever")
    end
end