realtime 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/realtime/realtime_controller.rb +52 -58
- data/lib/realtime/version.rb +1 -1
- metadata +1 -2
- data/README.rdoc +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79483830c5901410b149cb9bbe9ff5e550f664b3
|
4
|
+
data.tar.gz: 2482b7fafe2cd03287f5571324132ea0cc231f71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c29a63cb0ca55340755bb18bc82e93feeafe5ab2ebd6d48a21f390a005eb48f6ab790348d77b899651981b9df28a19ef9b1cec5697e25801646d87c607b95e0
|
7
|
+
data.tar.gz: 3a7c96950cd32c9355ec70ec50e020b8dc45695cbfacd195b93e0d9e98c79f70fa41f1a5dc515657c2a38b96785832ee40a7685feee40faad8065835439a969b
|
@@ -1,59 +1,53 @@
|
|
1
|
-
module Realtime
|
2
|
-
module Controller
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
|
5
|
-
module ClassMethods
|
6
|
-
def realtime_controller
|
7
|
-
before_filter :do_realtime_token
|
8
|
-
before_filter :
|
9
|
-
before_filter :
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
@realtime_token
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
@
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
@
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
def
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
RedisWrapper.redis.expire("rtSession-" + realtime_user_id.to_s, 86400)
|
54
|
-
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
1
|
+
module Realtime
|
2
|
+
module Controller
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
def realtime_controller
|
7
|
+
before_filter :do_realtime_token
|
8
|
+
before_filter :do_realtime_user_id
|
9
|
+
before_filter :do_realtime_server_url
|
10
|
+
after_filter :store_realtime_session
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def do_realtime_token
|
15
|
+
@realtime_token = Digest::MD5.hexdigest("#{session[:session_id]}:#{realtime_user_id}")
|
16
|
+
return @realtime_token
|
17
|
+
end
|
18
|
+
|
19
|
+
def do_realtime_user_id
|
20
|
+
@realtime_user_id = realtime_user_id
|
21
|
+
return @realtime_user_id
|
22
|
+
end
|
23
|
+
|
24
|
+
def do_realtime_server_url
|
25
|
+
@realtime_server_url = realtime_server_url
|
26
|
+
return @realtime_server_url
|
27
|
+
end
|
28
|
+
|
29
|
+
# create shared session tokens for redis/socketio realtime server running on node.js
|
30
|
+
def store_realtime_session
|
31
|
+
# store session data or any authentication data you want here, generate to JSON data
|
32
|
+
session_data = {
|
33
|
+
"user_id" => realtime_user_id,
|
34
|
+
}
|
35
|
+
|
36
|
+
# todo: merge additional session data passed in
|
37
|
+
|
38
|
+
stored_session_data = JSON.generate(session_data)
|
39
|
+
|
40
|
+
RedisWrapper.redis.hset(
|
41
|
+
"rtSession-" + realtime_user_id.to_s,
|
42
|
+
@realtime_token,
|
43
|
+
stored_session_data,
|
44
|
+
)
|
45
|
+
|
46
|
+
# expire this realtime session after one day.
|
47
|
+
RedisWrapper.redis.expire("rtSession-" + realtime_user_id.to_s, 86400)
|
48
|
+
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
59
53
|
end
|
data/lib/realtime/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: realtime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Atlas
|
@@ -55,7 +55,6 @@ files:
|
|
55
55
|
- lib/realtime/view_helpers.rb
|
56
56
|
- lib/realtime.rb
|
57
57
|
- MIT-LICENSE
|
58
|
-
- README.rdoc
|
59
58
|
homepage: https://github.com/mikeatlas/realtime-rails
|
60
59
|
licenses:
|
61
60
|
- MIT
|
data/README.rdoc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
= Realtime Support for Rails
|