Skip to content

Commit 064341d

Browse files
committed
Adds thin and sets up Faye in config.ru
Signed-off-by: Akash Manohar J <[email protected]>
1 parent 0c7890d commit 064341d

File tree

5 files changed

+58
-1
lines changed

5 files changed

+58
-1
lines changed

Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ gem 'sqlite3'
99
gem 'devise'
1010
gem 'devise_bushido_authenticatable'
1111
gem 'bushido'
12+
gem 'thin'
13+
gem 'faye'
1214

1315
# Gems used only for assets and not required
1416
# in production environments by default.

Gemfile.lock

+29
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ GEM
4747
activesupport (3.2.2)
4848
i18n (~> 0.6)
4949
multi_json (~> 1.0)
50+
addressable (2.2.7)
5051
arel (3.0.2)
5152
bcrypt-ruby (3.0.1)
5253
builder (3.0.0)
@@ -71,6 +72,8 @@ GEM
7172
coffee-script-source
7273
execjs
7374
coffee-script-source (1.2.0)
75+
cookiejar (0.3.0)
76+
daemons (1.1.8)
7477
devise (1.5.3)
7578
bcrypt-ruby (~> 3.0)
7679
orm_adapter (~> 0.0.3)
@@ -79,17 +82,36 @@ GEM
7982
devise (= 1.5.3)
8083
rubycas-client (>= 2.2.1)
8184
diff-lcs (1.1.3)
85+
em-http-request (1.0.1)
86+
addressable (>= 2.2.3)
87+
cookiejar
88+
em-socksify
89+
eventmachine (>= 1.0.0.beta.4)
90+
http_parser.rb (>= 0.5.3)
91+
em-socksify (0.1.0)
92+
eventmachine
8293
erubis (2.7.0)
94+
eventmachine (1.0.0.beta.4)
8395
execjs (1.3.0)
8496
multi_json (~> 1.0)
8597
factory_girl (2.6.1)
8698
activesupport (>= 2.3.9)
8799
factory_girl_rails (1.7.0)
88100
factory_girl (~> 2.6.0)
89101
railties (>= 3.0.0)
102+
faye (0.8.0)
103+
cookiejar (>= 0.3.0)
104+
em-http-request (>= 0.3.0)
105+
eventmachine (>= 0.12.0)
106+
faye-websocket (>= 0.4.0)
107+
rack (>= 1.0.0)
108+
yajl-ruby (>= 1.0.0)
109+
faye-websocket (0.4.1)
110+
eventmachine (>= 0.12.0)
90111
ffi (1.0.11)
91112
highline (1.6.11)
92113
hike (1.2.1)
114+
http_parser.rb (0.5.3)
93115
i18n (0.6.0)
94116
jasmine-core (1.2.0.rc1)
95117
journey (1.0.3)
@@ -168,6 +190,10 @@ GEM
168190
sqlite3 (1.3.5)
169191
therubyracer (0.9.10)
170192
libv8 (~> 3.3.10)
193+
thin (1.3.1)
194+
daemons (>= 1.0.9)
195+
eventmachine (>= 0.12.6)
196+
rack (>= 1.0.0)
171197
thor (0.14.6)
172198
tilt (1.3.3)
173199
treetop (1.4.10)
@@ -181,6 +207,7 @@ GEM
181207
rack (>= 1.0)
182208
xpath (0.1.4)
183209
nokogiri (~> 1.3)
210+
yajl-ruby (1.1.0)
184211

185212
PLATFORMS
186213
ruby
@@ -193,6 +220,7 @@ DEPENDENCIES
193220
devise_bushido_authenticatable
194221
ember-rails!
195222
factory_girl_rails
223+
faye
196224
jasmine!
197225
jquery-rails
198226
rails (= 3.2.2)
@@ -201,4 +229,5 @@ DEPENDENCIES
201229
shoulda-matchers
202230
sqlite3
203231
therubyracer
232+
thin
204233
uglifier (>= 1.0.3)

app/views/layouts/application.html.erb

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<title>Kandan</title>
55
<%= stylesheet_link_tag "application", :media => "all" %>
66
<%= javascript_include_tag "application" %>
7+
<%= javascript_include_tag "#{ENV['FAYEJS']}.js" %>
78
<%= csrf_meta_tags %>
89
</head>
910
<body>

config.ru

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
# This file is used by Rack-based servers to start the application.
22

33
require ::File.expand_path('../config/environment', __FILE__)
4-
run Kandan::Application
4+
require 'faye'
5+
6+
faye_server = Faye::RackAdapter.new(:mount => "/faye", :timeout => 5)
7+
8+
# TODO send pull request to faye to get this fixed
9+
# by adding a rack_prefix option
10+
# which should then make the faye server object available
11+
# via the get_client() method on the server
12+
13+
FAYE_CLIENT = faye_server.get_client
14+
15+
faye_server.bind(:subscribe) do |client_id|
16+
puts "SUBSCRIBE #{client_id}"
17+
end
18+
19+
faye_server.bind(:disconnect) do |client_id|
20+
puts "DISCONNECT #{client_id}"
21+
end
22+
23+
run Rack::URLMap.new({
24+
"/remote" => faye_server,
25+
"/" => Kandan::Application
26+
})
27+
28+
# run Kandan::Application

config/initializers/faye.rb

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ENV['FAYEJS'] ||= "/remote/faye"

0 commit comments

Comments
 (0)