Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

move event machine requires to apnserverd, add as develoipment depend…

…ency
  • Loading branch information...
commit 96ce40651fde5d5846e0b4bb36cfc9e0ca6808e0 1 parent 7fa0ea7
@bpoweski authored
View
2  Gemfile
@@ -2,7 +2,7 @@ source "http://rubygems.org"
gem "eventmachine"
gem "daemons"
-gem "activesupport", ">= 2.3"
+gem "activesupport", ">= 3.0.0"
gem "i18n" # active support whines without this
group :spec do
View
2  Gemfile.lock
@@ -19,7 +19,7 @@ PLATFORMS
ruby
DEPENDENCIES
- activesupport (>= 2.3)
+ activesupport (>= 3.0.0)
daemons
eventmachine
i18n
View
43 README.textile
@@ -5,16 +5,16 @@ h1. Apple Push Notification Server Toolkit
h2. Description
apnserver is a server and set of command line programs to send push notifications to the iPhone.
-Apple recommends to maintain an open connection to the push notification service and refrain from
-opening up and tearing down SSL connections repeated. To solve this problem an intermediate
-network server is introduced that queues are requests to the APN service and sends them via a
+Apple recommends to maintain an open connection to the push notification service and refrain from
+opening up and tearing down SSL connections repeated. To solve this problem an intermediate
+network server is introduced that queues are requests to the APN service and sends them via a
persistent connection.
h2. Remaining Tasks
-
+
* Implement feedback service mechanism
* Implement robust notification sending in reactor periodic scheduler
-
+
h2. Issues Fixed
* second attempt at retry logic, SSL Errors close down sockets now
@@ -26,33 +26,33 @@ h2. Issues Fixed
* moved to Rspec
h2. APN Server Daemon
-
+
<pre>
<code>
Usage: apnserverd [options] --pem /path/to/pem
--bind-address bind address (defaults to 0.0.0.0)
bind address of the server daemon
-
- --proxy-port port
+
+ --proxy-port port
the port that the daemon will listen on (defaults to 22195)
-
+
--server server
APN Server (defaults to gateway.push.apple.com)
-
+
--port port of the APN Server
APN server port (defaults to 2195)
-
+
--pem pem file path
The PEM encoded private key and certificate.
- To export a PEM ecoded file execute
+ To export a PEM ecoded file execute
# openssl pkcs12 -in cert.p12 -out cert.pem -nodes -clcerts
-
+
--pem-passphrase passphrase
The PEM passphrase to decode key.
-
+
--help
- usage message
-
+ usage message
+
--daemon
Runs process as daemon, not available on Windows
</code>
@@ -60,7 +60,7 @@ Usage: apnserverd [options] --pem /path/to/pem
h2. APN Server Client
-With the APN server client script you can send push notifications directly to
+With the APN server client script you can send push notifications directly to
Apple's APN server over an SSL connection or to the above daemon using a plain socket.
To send a notification to Apple's APN server using SSL the *--pem* option must be used.
@@ -69,7 +69,7 @@ To send a notification to Apple's APN server using SSL the *--pem* option must b
Usage: apnsend [switches] (--b64-token | --hex-token) <token>
--server <localhost> the apn server defaults to a locally running apnserverd
--port <2195> the port of the apn server
- --pem <path> the path to the pem file, if a pem is supplied the server
+ --pem <path> the path to the pem file, if a pem is supplied the server
defaults to gateway.push.apple.com:2195
--pem-passphrase <passphrase> the pem passphrase
--alert <message> the message to send"
@@ -101,6 +101,7 @@ To configure the client to send to the local apnserverd process configure the Ap
# configured for a using the apnserverd proxy
ApnServer::Config.host = 'localhost'
ApnServer::Config.port = 22195
+ ApnServer::Config.logger = Rails.logger
</code>
</pre>
@@ -130,8 +131,7 @@ Finally within we can send a push notification using the following code
h2. Installation
-Apnserver is hosted on "gemcutter":http://gemcutter.org/gems/apnserver and
-"Rubyforge":http://rubyforge.org/projects/apnserver/.
+Apnserver is hosted on "rubygems":https://rubygems.org/gems/apnserver
<pre>
<code>
@@ -143,10 +143,11 @@ Adding apnserver to your Rails application
<pre>
<code>
- config.gem "apnserver", :lib => 'apnserver', :version => ">= 0.1.10"
+ gem 'apnserver', '>= 0.2.0
</code>
</pre>
+
h2. License
(The MIT License)
View
3  apnserver.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = %q{apnserver}
- s.version = "0.2.0"
+ s.version = "0.2.1"
s.platform = Gem::Platform::RUBY
s.authors = ["Ben Poweski"]
@@ -21,4 +21,5 @@ Gem::Specification.new do |s|
s.required_rubygems_version = ">= 1.3.6"
s.add_dependency 'activesupport', '~> 3.0.0'
s.add_development_dependency 'bundler', '~> 1.0.0'
+ s.add_development_dependency 'eventmachine', '>= 0.12.8'
end
View
10 bin/apnsend
@@ -17,9 +17,9 @@ def usage
puts " --alert <message> the message to send"
puts " --sound <default> the sound to play, defaults to 'default'"
puts " --badge <number> the badge number"
- puts " --custom <json string> a custom json string to be added to the main object"
+ puts " --custom <json string> a custom json string to be added to the main object"
puts " --b64-token <token> a base 64 encoded device token"
- puts " --hex-token <token> a hex encoded device token"
+ puts " --hex-token <token> a hex encoded device token"
puts " --help this message"
end
@@ -31,7 +31,7 @@ opts = GetoptLong.new(
["--alert", "-a", GetoptLong::REQUIRED_ARGUMENT],
["--sound", "-S", GetoptLong::REQUIRED_ARGUMENT],
["--badge", "-b", GetoptLong::REQUIRED_ARGUMENT],
- ["--custom", "-j", GetoptLong::REQUIRED_ARGUMENT],
+ ["--custom", "-j", GetoptLong::REQUIRED_ARGUMENT],
["--b64-token", "-B", GetoptLong::REQUIRED_ARGUMENT],
["--hex-token", "-H", GetoptLong::REQUIRED_ARGUMENT],
["--help", "-h", GetoptLong::NO_ARGUMENT]
@@ -59,7 +59,7 @@ opts.each do |opt, arg|
when '--badge'
notification.badge = arg.to_i
when '--custom'
- notification.custom = arg
+ notification.custom = ActiveSupport::JSON.decode(arg)
when '--b64-token'
notification.device_token = Base64::decode64(arg)
when '--hex-token'
@@ -68,7 +68,7 @@ opts.each do |opt, arg|
end
if notification.device_token.nil?
- usage
+ usage
exit
else
notification.push
View
13 bin/apnserverd
@@ -5,6 +5,7 @@ require 'getoptlong'
require 'rubygems'
require 'daemons'
require 'apnserver'
+require 'apnserver/server'
def usage
puts "Usage: apnserverd [switches] --pem <path>"
@@ -21,11 +22,11 @@ end
def daemonize
Daemonize.daemonize(@log_file, 'apnserverd')
- open(@pid_file,"w") {|f| f.write(Process.pid) } # copied from mongrel
+ open(@pid_file,"w") { |f| f.write(Process.pid) }
open(@pid_file,"w") do |f|
f.write(Process.pid)
File.chmod(0644, @pid_file)
- end
+ end
end
opts = GetoptLong.new(
@@ -61,11 +62,11 @@ opts.each do |opt, arg|
when '--proxy-port'
proxy_port = arg.to_i
when '--server'
- host = arg
+ host = arg
when '--port'
- port = arg.to_i
- when '--pid'
- @pid_file = arg
+ port = arg.to_i
+ when '--pid'
+ @pid_file = arg
when '--log'
@log_file = arg
when '--pem'
View
5 lib/apnserver.rb
@@ -1,9 +1,4 @@
require 'logger'
-require 'eventmachine'
require 'apnserver/payload'
require 'apnserver/notification'
-require 'apnserver/protocol'
require 'apnserver/client'
-require 'apnserver/server_connection'
-require 'apnserver/server'
-
View
2  spec/support/test_server.rb
@@ -1,3 +1,5 @@
+require 'apnserver/protocol'
+
class TestServer
attr_accessor :queue
include ApnServer::Protocol
Please sign in to comment.
Something went wrong with that request. Please try again.