Sha256: 52a24acaf3cb1e578096a7fff3414a3929bb1abd0ecac703332502d0859ff506
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
require 'openssl' require 'socket' module Racoon class Client attr_accessor :pem, :host, :port, :password def initialize(pem, host = 'gateway.push.apple.com', port = 2195, pass = nil) @pem, @host, @port, @password = pem, host, port, pass end def connect! raise "Your certificate is not set." unless self.pem @context = OpenSSL::SSL::SSLContext.new @context.cert = OpenSSL::X509::Certificate.new(self.pem) @context.key = OpenSSL::PKey::RSA.new(self.pem, self.password) @sock = TCPSocket.new(self.host, self.port.to_i) @ssl = OpenSSL::SSL::SSLSocket.new(@sock, @context) @ssl.connect return @sock, @ssl end def disconnect! @ssl.close @sock.close @ssl = nil @sock = nil end def write(notification) if host.include? "sandbox" Config.logger.debug "#{Time.now} [#{host}:#{port}] Device: #{notification.device_token.unpack('H*')} sending #{notification.json_payload}" end @ssl.write(notification.to_bytes) end def connected? @ssl end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
racoon-0.4.0 | lib/racoon/client.rb |
racoon-0.3.2 | lib/racoon/client.rb |