class Crusade::APNS::SocketConnection
Attributes
configuration[RW]
host[RW]
port[RW]
Public Class Methods
new(configuration)
click to toggle source
# File lib/crusade/apns/socket_connection.rb, line 6 def initialize(configuration) self.configuration = configuration self.host = 'gateway.push.apple.com' self.port = 2195 end
Public Instance Methods
send(data)
click to toggle source
# File lib/crusade/apns/socket_connection.rb, line 13 def send data write data end
Private Instance Methods
context()
click to toggle source
# File lib/crusade/apns/socket_connection.rb, line 38 def context ssl_context = OpenSSL::SSL::SSLContext.new ssl_context.cert = OpenSSL::X509::Certificate.new(p12_certificate.certificate.to_pem) ssl_context.key = OpenSSL::PKey::RSA.new(p12_certificate.key.to_pem) ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE ssl_context end
open_connection()
click to toggle source
# File lib/crusade/apns/socket_connection.rb, line 21 def open_connection sock = TCPSocket.new(host, port) ssl = OpenSSL::SSL::SSLSocket.new(sock, context) ssl.connect return sock, ssl end
p12_certificate()
click to toggle source
# File lib/crusade/apns/socket_connection.rb, line 48 def p12_certificate @p12 ||= OpenSSL::PKCS12.new File.read(configuration.certificate), configuration.certificate_password end
write(binary)
click to toggle source
# File lib/crusade/apns/socket_connection.rb, line 29 def write binary sock, ssl = open_connection ssl.write(binary) ssl.close sock.close end