Class: Apnotic::Connection
- Inherits:
-
Object
- Object
- Apnotic::Connection
- Defined in:
- lib/apnotic/connection.rb
Instance Attribute Summary collapse
-
#cert_path ⇒ Object
readonly
Returns the value of attribute cert_path.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(options = {}) ⇒ Connection
constructor
A new instance of Connection.
- #push(notification, options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Connection
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/apnotic/connection.rb', line 21 def initialize(={}) @uri = URI.parse([:uri] || APPLE_PRODUCTION_SERVER_URI) @cert_path = [:cert_path] @cert_pass = [:cert_pass] @pipe_r, @pipe_w = Socket.pair(:UNIX, :STREAM, 0) @socket_thread = nil @mutex = Mutex.new raise "URI needs to be a HTTPS address" if uri.scheme != 'https' raise "Cert file not found: #{@cert_path}" unless @cert_path && File.exist?(@cert_path) end |
Instance Attribute Details
#cert_path ⇒ Object (readonly)
Returns the value of attribute cert_path.
12 13 14 |
# File 'lib/apnotic/connection.rb', line 12 def cert_path @cert_path end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
12 13 14 |
# File 'lib/apnotic/connection.rb', line 12 def uri @uri end |
Class Method Details
.development(options = {}) ⇒ Object
15 16 17 18 |
# File 'lib/apnotic/connection.rb', line 15 def development(={}) .merge!(uri: APPLE_DEVELOPMENT_SERVER_URI) new() end |
Instance Method Details
#close ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/apnotic/connection.rb', line 40 def close exit_thread(@socket_thread) @ssl_context = nil @h2 = nil @pipe_r = nil @pipe_w = nil @socket_thread = nil end |
#push(notification, options = {}) ⇒ Object
34 35 36 37 38 |
# File 'lib/apnotic/connection.rb', line 34 def push(notification, ={}) open new_stream.push(notification, ) end |