juggernaut 0.5.8 → 2.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README +7 -0
- data/Rakefile +16 -14
- data/VERSION +1 -0
- data/juggernaut.gemspec +47 -0
- data/lib/juggernaut.rb +12 -151
- metadata +43 -60
- data/Manifest.txt +0 -11
- data/README.txt +0 -32
- data/bin/juggernaut +0 -4
- data/lib/juggernaut/client.rb +0 -263
- data/lib/juggernaut/message.rb +0 -19
- data/lib/juggernaut/miscel.rb +0 -27
- data/lib/juggernaut/runner.rb +0 -219
- data/lib/juggernaut/server.rb +0 -368
- data/lib/juggernaut/utils.rb +0 -11
- data/test/test_client.rb +0 -176
- data/test/test_juggernaut.rb +0 -34
- data/test/test_message.rb +0 -26
- data/test/test_runner.rb +0 -26
- data/test/test_server.rb +0 -573
- data/test/test_utils.rb +0 -26
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Alexander MacCaw
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
data/Rakefile
CHANGED
@@ -1,16 +1,18 @@
|
|
1
|
-
# -*- ruby -*-
|
2
|
-
|
3
1
|
require 'rubygems'
|
4
|
-
require '
|
5
|
-
require './lib/juggernaut.rb'
|
6
|
-
|
7
|
-
Hoe.new('juggernaut', Juggernaut::VERSION) do |p|
|
8
|
-
p.rubyforge_name = 'juggernaut'
|
9
|
-
p.author = 'Alex MacCaw'
|
10
|
-
p.email = 'info@eribium.org'
|
11
|
-
p.url = 'http://juggernaut.rubyforge.org'
|
12
|
-
p.extra_deps << ['eventmachine', '>=0.10.0']
|
13
|
-
p.extra_deps << ['json', '>=1.1.2']
|
14
|
-
end
|
2
|
+
require 'rake'
|
15
3
|
|
16
|
-
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "juggernaut"
|
8
|
+
gem.summary = %Q{Simple realtime push}
|
9
|
+
gem.description = %Q{Use Juggernaut to easily implement realtime chat, collaboration, gaming and much more!}
|
10
|
+
gem.email = "info@eribium.org"
|
11
|
+
gem.homepage = "http://github.com/maccman/juggernaut"
|
12
|
+
gem.authors = ["Alex MacCaw"]
|
13
|
+
gem.add_dependency "redis", ">= 0"
|
14
|
+
end
|
15
|
+
Jeweler::GemcutterTasks.new
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
18
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0.beta1
|
data/juggernaut.gemspec
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{juggernaut}
|
8
|
+
s.version = "2.0.0.beta1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Alex MacCaw"]
|
12
|
+
s.date = %q{2010-09-03}
|
13
|
+
s.description = %q{Use Juggernaut to easily implement realtime chat, collaboration, gaming and much more!}
|
14
|
+
s.email = %q{info@eribium.org}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".document",
|
20
|
+
".gitignore",
|
21
|
+
"LICENSE",
|
22
|
+
"README",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"juggernaut.gemspec",
|
26
|
+
"lib/juggernaut.rb"
|
27
|
+
]
|
28
|
+
s.homepage = %q{http://github.com/maccman/juggernaut}
|
29
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
30
|
+
s.require_paths = ["lib"]
|
31
|
+
s.rubygems_version = %q{1.3.7}
|
32
|
+
s.summary = %q{Simple realtime push}
|
33
|
+
|
34
|
+
if s.respond_to? :specification_version then
|
35
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
36
|
+
s.specification_version = 3
|
37
|
+
|
38
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
39
|
+
s.add_runtime_dependency(%q<redis>, [">= 0"])
|
40
|
+
else
|
41
|
+
s.add_dependency(%q<redis>, [">= 0"])
|
42
|
+
end
|
43
|
+
else
|
44
|
+
s.add_dependency(%q<redis>, [">= 0"])
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
data/lib/juggernaut.rb
CHANGED
@@ -1,158 +1,19 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require 'eventmachine'
|
4
|
-
require 'json'
|
5
|
-
$:.unshift(File.dirname(__FILE__))
|
1
|
+
require "redis"
|
2
|
+
require "json"
|
6
3
|
|
7
4
|
module Juggernaut
|
8
|
-
|
9
|
-
|
10
|
-
class JuggernautError < StandardError #:nodoc:
|
5
|
+
def redis
|
6
|
+
@redis ||= Redis.new
|
11
7
|
end
|
12
|
-
|
13
|
-
@@options = {}
|
14
8
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
# ======================
|
19
|
-
|
20
|
-
# === Subscription authentication ===
|
21
|
-
# Leave all subscription options uncommented to allow anyone to subscribe.
|
22
|
-
|
23
|
-
# If specified, subscription_url is called everytime a client subscribes.
|
24
|
-
# Parameters passed are: session_id, client_id and an array of channels.
|
25
|
-
#
|
26
|
-
# The server should check that the session_id matches up to the client_id
|
27
|
-
# and that the client is allowed to access the specified channels.
|
28
|
-
#
|
29
|
-
# If a status code other than 200 is encountered, the subscription_request fails
|
30
|
-
# and the client is disconnected.
|
31
|
-
#
|
32
|
-
# :subscription_url: http://localhost:3000/sessions/juggernaut_subscription
|
33
|
-
|
34
|
-
# === Broadcast and query authentication ===
|
35
|
-
# Leave all broadcast/query options uncommented to allow anyone to broadcast/query.
|
36
|
-
#
|
37
|
-
# Broadcast authentication in a production environment is very importantant since broadcasters
|
38
|
-
# can execute JavaScript on subscribed clients, leaving you vulnerable to cross site scripting
|
39
|
-
# attacks if broadcasters aren't authenticated.
|
40
|
-
|
41
|
-
# 1) Via IP address
|
42
|
-
#
|
43
|
-
# If specified, if a client has an ip that is specified in allowed_ips, than it is automatically
|
44
|
-
# authenticated, even if a secret_key isn't provided.
|
45
|
-
#
|
46
|
-
# This is the recommended method for broadcast authentication.
|
47
|
-
#
|
48
|
-
:allowed_ips:
|
49
|
-
- 127.0.0.1
|
50
|
-
# - 192.168.0.1
|
51
|
-
|
52
|
-
# 2) Via HTTP request
|
53
|
-
#
|
54
|
-
# If specified, if a client attempts a broadcast/query, without a secret_key or using an IP
|
55
|
-
# no included in allowed_ips, then broadcast_query_login_url will be called.
|
56
|
-
# Parameters passed, if given, are: session_id, client_id, channels and type.
|
57
|
-
#
|
58
|
-
# The server should check that the session_id matches up to the client id, and the client
|
59
|
-
# is allowed to perform that particular type of broadcast/query.
|
60
|
-
#
|
61
|
-
# If a status code other than 200 is encountered, the broadcast_query_login_url fails
|
62
|
-
# and the client is disconnected.
|
63
|
-
#
|
64
|
-
# :broadcast_query_login_url: http://localhost:3000/sessions/juggernaut_broadcast
|
65
|
-
|
66
|
-
# 3) Via shared secret key
|
67
|
-
#
|
68
|
-
# This secret key must be sent with any query/broadcast commands.
|
69
|
-
# It must be the same as the one in the Rails config file.
|
70
|
-
#
|
71
|
-
# You shouldn't authenticate broadcasts from subscribed clients using this method
|
72
|
-
# since the secret_key will be easily visible in the page (and not so secret any more)!
|
73
|
-
#
|
74
|
-
# :secret_key: your_secret_key_here
|
75
|
-
|
76
|
-
# == Subscription Logout ==
|
77
|
-
|
78
|
-
# If specified, logout_connection_url is called everytime a specific connection from a subscribed client disconnects.
|
79
|
-
# Parameters passed are session_id, client_id and an array of channels specific to that connection.
|
80
|
-
#
|
81
|
-
# :logout_connection_url: http://localhost:3000/sessions/juggernaut_connection_logout
|
82
|
-
|
83
|
-
# Logout url is called when all connections from a subscribed client are closed.
|
84
|
-
# Parameters passed are session_id and client_id.
|
85
|
-
#
|
86
|
-
# :logout_url: http://localhost:3000/sessions/juggernaut_logout
|
87
|
-
|
88
|
-
# === Miscellaneous ===
|
89
|
-
|
90
|
-
# timeout defaults to 10. A timeout is the time between when a client closes a connection
|
91
|
-
# and a logout_request or logout_connection_request is made. The reason for this is that a client
|
92
|
-
# may only temporarily be disconnected, and may attempt a reconnect very soon.
|
93
|
-
#
|
94
|
-
# :timeout: 10
|
95
|
-
|
96
|
-
# store_messages defaults to false. If this option is true, messages send to connections will be stored.
|
97
|
-
# This is useful since a client can then receive broadcasted message that it has missed (perhaps it was disconnected).
|
98
|
-
#
|
99
|
-
# :store_messages: false
|
100
|
-
|
101
|
-
# === Server ===
|
102
|
-
|
103
|
-
# Host defaults to "0.0.0.0". You shouldn't need to change this.
|
104
|
-
# :host: 0.0.0.0
|
105
|
-
|
106
|
-
# Port is mandatory
|
107
|
-
:port: 5001
|
108
|
-
|
109
|
-
# Defaults to value of :port. If you are doing port forwarding you'll need to configure this to the same
|
110
|
-
# value as :public_port in the juggernaut_hosts.yml file
|
111
|
-
# :public_port: 5001
|
112
|
-
|
113
|
-
EOF
|
9
|
+
def redis=(val)
|
10
|
+
@redis = val
|
11
|
+
end
|
114
12
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
end
|
119
|
-
|
120
|
-
def options=(val)
|
121
|
-
@@options = val
|
122
|
-
end
|
123
|
-
|
124
|
-
def logger
|
125
|
-
return @@logger if defined?(@@logger) && !@@logger.nil?
|
126
|
-
FileUtils.mkdir_p(File.dirname(log_path))
|
127
|
-
@@logger = Logger.new(log_path)
|
128
|
-
@@logger.level = Logger::INFO if options[:debug] == false
|
129
|
-
@@logger
|
130
|
-
rescue
|
131
|
-
@@logger = Logger.new(STDOUT)
|
132
|
-
end
|
133
|
-
|
134
|
-
def logger=(logger)
|
135
|
-
@@logger = logger
|
136
|
-
end
|
137
|
-
|
138
|
-
def log_path
|
139
|
-
options[:log_path] || File.join(%w( / var run juggernaut.log ))
|
140
|
-
end
|
141
|
-
|
142
|
-
def pid_path
|
143
|
-
options[:pid_path] || File.join(%w( / var run ), "juggernaut.#{options[:port]}.pid" )
|
144
|
-
end
|
145
|
-
|
146
|
-
def config_path
|
147
|
-
options[:config_path] || File.join(%w( / var run juggernaut.yml ))
|
148
|
-
end
|
149
|
-
|
13
|
+
def publish(channels, data)
|
14
|
+
message = {:channels => Array(channels), :data => data}
|
15
|
+
redis.publish(:juggernaut, message.to_json)
|
150
16
|
end
|
151
|
-
end
|
152
17
|
|
153
|
-
|
154
|
-
|
155
|
-
require 'juggernaut/message'
|
156
|
-
require 'juggernaut/client'
|
157
|
-
require 'juggernaut/server'
|
158
|
-
require 'juggernaut/runner'
|
18
|
+
extend self
|
19
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: juggernaut
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: true
|
5
|
+
segments:
|
6
|
+
- 2
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- beta1
|
10
|
+
version: 2.0.0.beta1
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Alex MacCaw
|
@@ -9,95 +15,72 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date:
|
18
|
+
date: 2010-09-03 00:00:00 +01:00
|
13
19
|
default_executable:
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
17
|
-
|
18
|
-
|
19
|
-
|
22
|
+
name: redis
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
20
26
|
requirements:
|
21
27
|
- - ">="
|
22
28
|
- !ruby/object:Gem::Version
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
name: json
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
27
32
|
type: :runtime
|
28
|
-
|
29
|
-
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.1.2
|
34
|
-
version:
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: hoe
|
37
|
-
type: :development
|
38
|
-
version_requirement:
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
41
|
-
- - ">="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: 2.3.3
|
44
|
-
version:
|
45
|
-
description: |-
|
46
|
-
See Plugin README:
|
47
|
-
http://juggernaut.rubyforge.org/svn/trunk/juggernaut/README
|
33
|
+
version_requirements: *id001
|
34
|
+
description: Use Juggernaut to easily implement realtime chat, collaboration, gaming and much more!
|
48
35
|
email: info@eribium.org
|
49
|
-
executables:
|
50
|
-
|
36
|
+
executables: []
|
37
|
+
|
51
38
|
extensions: []
|
52
39
|
|
53
40
|
extra_rdoc_files:
|
54
|
-
-
|
55
|
-
- README.txt
|
41
|
+
- README
|
56
42
|
files:
|
57
|
-
-
|
58
|
-
-
|
43
|
+
- .document
|
44
|
+
- .gitignore
|
45
|
+
- LICENSE
|
46
|
+
- README
|
59
47
|
- Rakefile
|
60
|
-
-
|
48
|
+
- VERSION
|
49
|
+
- juggernaut.gemspec
|
61
50
|
- lib/juggernaut.rb
|
62
|
-
- lib/juggernaut/client.rb
|
63
|
-
- lib/juggernaut/message.rb
|
64
|
-
- lib/juggernaut/miscel.rb
|
65
|
-
- lib/juggernaut/runner.rb
|
66
|
-
- lib/juggernaut/server.rb
|
67
|
-
- lib/juggernaut/utils.rb
|
68
51
|
has_rdoc: true
|
69
|
-
homepage: http://juggernaut
|
52
|
+
homepage: http://github.com/maccman/juggernaut
|
70
53
|
licenses: []
|
71
54
|
|
72
55
|
post_install_message:
|
73
56
|
rdoc_options:
|
74
|
-
- --
|
75
|
-
- README.txt
|
57
|
+
- --charset=UTF-8
|
76
58
|
require_paths:
|
77
59
|
- lib
|
78
60
|
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
79
62
|
requirements:
|
80
63
|
- - ">="
|
81
64
|
- !ruby/object:Gem::Version
|
65
|
+
segments:
|
66
|
+
- 0
|
82
67
|
version: "0"
|
83
|
-
version:
|
84
68
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
85
70
|
requirements:
|
86
|
-
- - "
|
71
|
+
- - ">"
|
87
72
|
- !ruby/object:Gem::Version
|
88
|
-
|
89
|
-
|
73
|
+
segments:
|
74
|
+
- 1
|
75
|
+
- 3
|
76
|
+
- 1
|
77
|
+
version: 1.3.1
|
90
78
|
requirements: []
|
91
79
|
|
92
|
-
rubyforge_project:
|
93
|
-
rubygems_version: 1.3.
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 1.3.7
|
94
82
|
signing_key:
|
95
83
|
specification_version: 3
|
96
|
-
summary:
|
97
|
-
test_files:
|
98
|
-
|
99
|
-
- test/test_juggernaut.rb
|
100
|
-
- test/test_message.rb
|
101
|
-
- test/test_runner.rb
|
102
|
-
- test/test_server.rb
|
103
|
-
- test/test_utils.rb
|
84
|
+
summary: Simple realtime push
|
85
|
+
test_files: []
|
86
|
+
|