realtime 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 309951657b8931484acf28fac6ab5c3f4e877da1
4
- data.tar.gz: 56c50b2aaf6589956e9fea4160a1a21454ea23cf
3
+ metadata.gz: c3ec19eba97229354e064d27bfc0b92b0911a3d8
4
+ data.tar.gz: 4ea1fd69755b1b971838b592ccb5eac0caa06e3d
5
5
  SHA512:
6
- metadata.gz: 67b5d6d9f1b2ae290f349e82fd9e558b0dd76908c2d70954adb7341aa854266c880e94f779e99cc72f767a67becf0a9de153a73a5978b40287b201dc25699f2c
7
- data.tar.gz: 6e63aa93e9592bd2507a4521ffcaad7291e925db019ef0f7e3bb2b31c2410e03b08d0ae19d2ac989299f14171b06c3e98d94887a4adbe52236e3cc3609667480
6
+ metadata.gz: df907e7537971450e92f4ca3960a1cb53b5bae9deb9d4db38732709487021c10772f6bf7f560b444812a8f3c402768b4aa29dabdc11dcdbdf30212328fa656c7
7
+ data.tar.gz: ea678d1709d3eff430de67e890528fbe5ef43f3b994af83ac0f67366099ca83ad6bf5f99f64d5800a4ae448da0722d65c87cc2700ce99981519f9b7693f0190e
@@ -1,6 +1,6 @@
1
-
2
- require "realtime/realtime_controller.rb"
3
- require "realtime/redis_wrapper.rb"
4
- require "realtime/zmq_wrapper.rb"
5
- require 'realtime/view_helpers.rb'
6
- require 'realtime/railtie.rb'
1
+
2
+ require "realtime/realtime_controller.rb"
3
+ require "realtime/redis_wrapper.rb"
4
+ require "realtime/zmq_wrapper.rb"
5
+ require 'realtime/view_helpers.rb'
6
+ require 'realtime/railtie.rb'
@@ -1,75 +1,75 @@
1
- module Realtime
2
- module Controller
3
- extend ActiveSupport::Concern
4
-
5
- module ClassMethods
6
- def realtime_controller(options = nil)
7
- before_filter :do_realtime_token
8
- before_filter :do_realtime_user_id
9
- before_filter :do_realtime_server_url
10
- if options.nil?
11
- after_filter :store_realtime_session_redis
12
- elsif options[:queue] == :redis
13
- after_filter :store_realtime_session_redis
14
- elsif options[:queue] == :zmq
15
- after_filter :store_realtime_session_zmq
16
- end
17
- end
18
- end
19
-
20
- def do_realtime_token
21
- @realtime_token = Digest::MD5.hexdigest("#{session[:session_id]}:#{realtime_user_id}")
22
- return @realtime_token
23
- end
24
-
25
- def do_realtime_user_id
26
- @realtime_user_id = realtime_user_id
27
- return @realtime_user_id
28
- end
29
-
30
- def do_realtime_server_url
31
- @realtime_server_url = realtime_server_url
32
- return @realtime_server_url
33
- end
34
-
35
- # create shared session tokens for redis/socketio realtime server running on node.js
36
- def store_realtime_session_zmq
37
- # store session data or any authentication data you want here, generate to JSON data
38
- session_data = {
39
- "user_id" => realtime_user_id,
40
- }
41
-
42
- # todo: merge additional session data passed in
43
- stored_session_data = JSON.generate(session_data)
44
-
45
- ZmqWrapper.store_session(
46
- realtime_user_id,
47
- @realtime_token,
48
- stored_session_data,
49
- 86400
50
- )
51
- end
52
-
53
- # create shared session tokens for redis/socketio realtime server running on node.js
54
- def store_realtime_session_redis
55
- # store session data or any authentication data you want here, generate to JSON data
56
- session_data = {
57
- "user_id" => realtime_user_id,
58
- }
59
-
60
- # todo: merge additional session data passed in
61
-
62
- stored_session_data = JSON.generate(session_data)
63
-
64
- RedisWrapper.redis.hset(
65
- "rtSession-" + realtime_user_id.to_s,
66
- @realtime_token,
67
- stored_session_data,
68
- )
69
-
70
- # expire this realtime session after one day.
71
- RedisWrapper.redis.expire("rtSession-" + realtime_user_id.to_s, 86400)
72
- end
73
-
74
- end
1
+ module Realtime
2
+ module Controller
3
+ extend ActiveSupport::Concern
4
+
5
+ module ClassMethods
6
+ def realtime_controller(options = nil)
7
+ before_filter :do_realtime_token
8
+ before_filter :do_realtime_user_id
9
+ before_filter :do_realtime_server_url
10
+ if options.nil?
11
+ after_filter :store_realtime_session_redis
12
+ elsif options[:queue] == :redis
13
+ after_filter :store_realtime_session_redis
14
+ elsif options[:queue] == :zmq
15
+ after_filter :store_realtime_session_zmq
16
+ end
17
+ end
18
+ end
19
+
20
+ def do_realtime_token
21
+ @realtime_token = Digest::MD5.hexdigest("#{session[:session_id]}:#{realtime_user_id}")
22
+ return @realtime_token
23
+ end
24
+
25
+ def do_realtime_user_id
26
+ @realtime_user_id = realtime_user_id
27
+ return @realtime_user_id
28
+ end
29
+
30
+ def do_realtime_server_url
31
+ @realtime_server_url = realtime_server_url
32
+ return @realtime_server_url
33
+ end
34
+
35
+ # create shared session tokens for redis/socketio realtime server running on node.js
36
+ def store_realtime_session_zmq
37
+ # store session data or any authentication data you want here, generate to JSON data
38
+ session_data = {
39
+ "user_id" => realtime_user_id,
40
+ }
41
+
42
+ # todo: merge additional session data passed in
43
+ stored_session_data = JSON.generate(session_data)
44
+
45
+ ZmqWrapper.store_session(
46
+ realtime_user_id,
47
+ @realtime_token,
48
+ stored_session_data,
49
+ 86400
50
+ )
51
+ end
52
+
53
+ # create shared session tokens for redis/socketio realtime server running on node.js
54
+ def store_realtime_session_redis
55
+ # store session data or any authentication data you want here, generate to JSON data
56
+ session_data = {
57
+ "user_id" => realtime_user_id,
58
+ }
59
+
60
+ # todo: merge additional session data passed in
61
+
62
+ stored_session_data = JSON.generate(session_data)
63
+
64
+ RedisWrapper.redis.hset(
65
+ "rtSession-" + realtime_user_id.to_s,
66
+ @realtime_token,
67
+ stored_session_data,
68
+ )
69
+
70
+ # expire this realtime session after one day.
71
+ RedisWrapper.redis.expire("rtSession-" + realtime_user_id.to_s, 86400)
72
+ end
73
+
74
+ end
75
75
  end
@@ -1,3 +1,3 @@
1
- module Realtime
2
- VERSION = "0.0.11"
3
- end
1
+ module Realtime
2
+ VERSION = "0.0.12"
3
+ end
@@ -1,34 +1,34 @@
1
- class ZmqWrapper
2
-
3
- if defined?(ZMQ) && defined?(EmZeromq)
4
- require 'em-zeromq'
5
-
6
- def self.publish(the_message)
7
- EM.run {
8
- zmq = EM::ZeroMQ::Context.new(1)
9
- pusher = zmq.socket(ZMQ::PUSH)
10
- pusher.connect($zmq_server)
11
- message = "realtime_msg:" + the_message.to_json
12
- puts "Pushing realtime message: " + message
13
- pusher.send_msg(message)
14
- EM.stop
15
- }
16
- end
17
-
18
- def self.store_session(user_id, session_id, session_data, expiration)
19
- EM.run {
20
- zmq = EM::ZeroMQ::Context.new(1)
21
- pusher = zmq.socket(ZMQ::PUSH)
22
- pusher.connect($zmq_server)
23
- the_message = {user_id: user_id,
24
- session_id: session_id,
25
- session_data: session_data,
26
- expiration: expiration}
27
- message = "rtSession:" + the_message.to_json
28
- puts "Pushing session message: " + message
29
- pusher.send_msg(message)
30
- EM.stop
31
- }
32
- end
33
- end
34
- end
1
+ class ZmqWrapper
2
+
3
+ if defined?(ZMQ) && defined?(EmZeromq)
4
+ require 'em-zeromq'
5
+
6
+ def self.publish(the_message)
7
+ EM.run {
8
+ zmq = EM::ZeroMQ::Context.new(1)
9
+ pusher = zmq.socket(ZMQ::PUSH)
10
+ pusher.connect($zmq_server)
11
+ message = "realtime_msg:" + the_message.to_json
12
+ puts "Pushing realtime message: " + message
13
+ pusher.send_msg(message)
14
+ EM.stop
15
+ }
16
+ end
17
+
18
+ def self.store_session(user_id, session_id, session_data, expiration)
19
+ EM.run {
20
+ zmq = EM::ZeroMQ::Context.new(1)
21
+ pusher = zmq.socket(ZMQ::PUSH)
22
+ pusher.connect($zmq_server)
23
+ the_message = {user_id: user_id,
24
+ session_id: session_id,
25
+ session_data: session_data,
26
+ expiration: expiration}
27
+ message = "rtSession:" + the_message.to_json
28
+ puts "Pushing session message: " + message
29
+ pusher.send_msg(message)
30
+ EM.stop
31
+ }
32
+ end
33
+ end
34
+ end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: realtime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Atlas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-10 00:00:00.000000000 Z
11
+ date: 2014-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.0'
27
27
  description: Provides a simple Realtime framework for Rails applications.
@@ -31,17 +31,17 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - MIT-LICENSE
35
34
  - app/views/realtime/realtime_message_console_logger.html.erb
36
35
  - app/views/realtime/realtime_message_handler.html.erb
37
36
  - app/views/realtime/realtime_support.html.erb
38
- - lib/realtime.rb
39
37
  - lib/realtime/railtie.rb
40
38
  - lib/realtime/realtime_controller.rb
41
39
  - lib/realtime/redis_wrapper.rb
42
40
  - lib/realtime/version.rb
43
41
  - lib/realtime/view_helpers.rb
44
42
  - lib/realtime/zmq_wrapper.rb
43
+ - lib/realtime.rb
44
+ - MIT-LICENSE
45
45
  homepage: http://mikeatlas.github.io/realtime-rails/
46
46
  licenses:
47
47
  - MIT
@@ -52,17 +52,17 @@ require_paths:
52
52
  - lib
53
53
  required_ruby_version: !ruby/object:Gem::Requirement
54
54
  requirements:
55
- - - ">="
55
+ - - '>='
56
56
  - !ruby/object:Gem::Version
57
57
  version: '0'
58
58
  required_rubygems_version: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ">="
60
+ - - '>='
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
63
  requirements: []
64
64
  rubyforge_project:
65
- rubygems_version: 2.2.2
65
+ rubygems_version: 2.0.3
66
66
  signing_key:
67
67
  specification_version: 4
68
68
  summary: Realtime support for Rails applications.