rsence 2.0.0.6.pre → 2.0.0.7.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/INSTALL.rdoc +39 -25
- data/VERSION +1 -1
- data/conf/default_conf.yaml +0 -3
- data/lib/conf/default.rb +59 -60
- data/lib/daemon/daemon.rb +269 -280
- data/lib/http/broker.rb +47 -14
- data/lib/http/rackup.rb +4 -0
- data/lib/http/request.rb +47 -49
- data/lib/http/response.rb +47 -45
- data/lib/plugins/gui_plugin.rb +22 -21
- data/lib/plugins/guiparser.rb +95 -94
- data/lib/plugins/plugin.rb +300 -295
- data/lib/plugins/plugin_plugins.rb +64 -40
- data/lib/plugins/plugin_sqlite_db.rb +63 -63
- data/lib/plugins/plugin_util.rb +95 -104
- data/lib/plugins/pluginmanager.rb +373 -414
- data/lib/plugins/plugins.rb +11 -4
- data/lib/plugins/servlet.rb +10 -9
- data/lib/session/msg.rb +249 -248
- data/lib/session/sessionmanager.rb +364 -373
- data/lib/session/sessionstorage.rb +265 -272
- data/lib/transporter/transporter.rb +164 -169
- data/lib/util/gzstring.rb +2 -0
- data/lib/values/hvalue.rb +224 -224
- data/lib/values/valuemanager.rb +98 -98
- data/plugins/index_html/index_html.rb +1 -32
- metadata +4 -4
data/lib/values/valuemanager.rb
CHANGED
@@ -15,143 +15,143 @@ require 'randgen'
|
|
15
15
|
|
16
16
|
module RSence
|
17
17
|
|
18
|
-
## ValueManager provides automagic, transparent syncronization of values between client and server.
|
19
|
-
class ValueManager
|
18
|
+
## ValueManager provides automagic, transparent syncronization of values between client and server.
|
19
|
+
class ValueManager
|
20
20
|
|
21
|
-
|
21
|
+
attr_accessor :randgen
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
# Initializes the member value handler objects.
|
24
|
+
def initialize
|
25
25
|
|
26
|
-
|
26
|
+
@config = ::RSence.config[:session_conf]
|
27
27
|
|
28
|
-
|
29
|
-
|
28
|
+
## 'Unique' Random String generator for HValue keys (passed on to the client)
|
29
|
+
@randgen = RandGen.new( @config[:key_length] )
|
30
30
|
|
31
|
-
|
31
|
+
end
|
32
32
|
|
33
|
-
|
34
|
-
|
33
|
+
# Re-constructs all stored values and sends them to the client
|
34
|
+
def resend_session_values( msg )
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
# with disposable keys enabled,
|
37
|
+
# sessions restored from cookie_key replace
|
38
|
+
# all val_id:s with new ones
|
39
|
+
if @config[:disposable_keys]
|
40
40
|
|
41
|
-
|
42
|
-
|
41
|
+
# get the session values
|
42
|
+
ses_values = msg.session[:values]
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
# loop through the value id:s
|
45
|
+
old_ids = ses_values[:by_id].keys
|
46
|
+
old_ids.each do |old_id|
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
# make a new id
|
49
|
+
new_id = @randgen.gen
|
50
|
+
new_id = @randgen.gen while id_exists?( msg, new_id )
|
51
51
|
|
52
|
-
|
53
|
-
|
52
|
+
# get the hvalue
|
53
|
+
val_obj = ses_values[:by_id][old_id]
|
54
54
|
|
55
|
-
|
56
|
-
|
55
|
+
# replace the old id in the hvalue itself
|
56
|
+
val_obj.val_id = new_id
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
# re-associate the value with the new id
|
59
|
+
ses_values[:by_id][new_id] = val_obj
|
60
|
+
ses_values[:by_id].delete(old_id)
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
62
|
+
# replace the id in the unvalidated values (:check) array
|
63
|
+
if ses_values[:check].include?(old_id)
|
64
|
+
old_idx = ses_values[:check].index(old_id)
|
65
|
+
ses_values[:check][old_idx] = new_id
|
66
|
+
end
|
67
67
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
68
|
+
# replace the id in the unsynchronized values (:sync) array
|
69
|
+
if ses_values[:sync].include?(old_id)
|
70
|
+
old_idx = ses_values[:sync].index(old_id)
|
71
|
+
ses_values[:sync][old_idx] = new_id
|
72
|
+
end
|
73
73
|
|
74
|
-
|
75
|
-
|
74
|
+
# tell the hvalue to send its client-side initialization
|
75
|
+
val_obj.restore( msg )
|
76
76
|
|
77
|
-
|
77
|
+
end
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
79
|
+
## keeping the id:s between page reloads is faster, but less tamper-proof
|
80
|
+
else
|
81
|
+
msg.session[:values][:by_id].each_key do |val_id|
|
82
|
+
msg.session[:values][:by_id][val_id].restore( msg )
|
83
|
+
end
|
83
84
|
end
|
84
|
-
end
|
85
85
|
|
86
|
-
|
86
|
+
end
|
87
87
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
88
|
+
# Verifies an
|
89
|
+
def id_exists?( msg, new_id )
|
90
|
+
return msg.session[:values][:by_id].has_key?(new_id)
|
91
|
+
end
|
92
92
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
93
|
+
# Parses the json from the client and passes it on to associated values
|
94
|
+
def xhr( msg, syncdata_str )
|
95
|
+
|
96
|
+
# parses the json data sent by the client
|
97
|
+
syncdata = JSON.parse( syncdata_str )
|
98
|
+
|
99
|
+
session_values = msg.session[:values][:by_id]
|
100
|
+
syncdata.each do |value_key, value_data|
|
101
|
+
if session_values.has_key?( value_key )
|
102
|
+
value_obj = session_values[ value_key ]
|
103
|
+
value_obj.from_client( msg, value_data )
|
104
|
+
else
|
105
|
+
raise "HValue; unassigned value id! (#{val_id.inspect})"
|
106
|
+
end
|
106
107
|
end
|
107
108
|
end
|
108
|
-
end
|
109
109
|
|
110
|
-
|
111
|
-
|
110
|
+
# Sets a value by id
|
111
|
+
def set( msg, val_id, val_data )
|
112
112
|
|
113
|
-
|
114
|
-
|
113
|
+
# get the session data of this session
|
114
|
+
session_values = msg.session[:values][:by_id]
|
115
115
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
116
|
+
# tell the value of that id that it has new data
|
117
|
+
val_obj = session_values[ val_id ]
|
118
|
+
val_obj.set( msg, val_data )
|
119
|
+
end
|
120
120
|
|
121
|
-
|
122
|
-
|
121
|
+
# Validates the new data of all client-side-modified session-bound values
|
122
|
+
def validate( msg )
|
123
123
|
|
124
|
-
|
125
|
-
|
124
|
+
# get the session data of this session
|
125
|
+
session_values = msg.session[:values]
|
126
126
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
127
|
+
# loop through un-validated values and validate them
|
128
|
+
check_ids = session_values[:check]
|
129
|
+
check_ids.each do |check_id|
|
130
|
+
session_values[:by_id][check_id].tell( msg )
|
131
|
+
end
|
132
132
|
|
133
|
-
|
133
|
+
end
|
134
134
|
|
135
|
-
|
136
|
-
|
135
|
+
# Sends the new data of all server-side-modified session-bound values to the client
|
136
|
+
def sync_client( msg )
|
137
137
|
|
138
|
-
|
139
|
-
|
138
|
+
# get the session data of this session
|
139
|
+
session_values = msg.session[:values]
|
140
140
|
|
141
|
-
|
142
|
-
|
141
|
+
# go through the currently un-synced values
|
142
|
+
session_values[:sync].size.times do |count_num|
|
143
143
|
|
144
|
-
|
145
|
-
|
144
|
+
# the sync-array will return the value id
|
145
|
+
val_id = session_values[:sync].shift
|
146
146
|
|
147
|
-
|
148
|
-
|
147
|
+
# tell the value of that id to report its state to the client
|
148
|
+
session_values[:by_id][val_id].to_client( msg )
|
149
149
|
|
150
|
-
|
150
|
+
end
|
151
151
|
|
152
|
-
|
152
|
+
end
|
153
153
|
|
154
|
-
end
|
154
|
+
end
|
155
155
|
|
156
156
|
|
157
157
|
end
|
@@ -6,11 +6,7 @@
|
|
6
6
|
# with this software package. If not, contact licensing@riassence.com
|
7
7
|
##
|
8
8
|
|
9
|
-
|
10
|
-
IndexHtmlPlugin is the servlet plugin that is responsible for initializing the "boot-strap page".
|
11
|
-
|
12
|
-
It just loads, caches and sends the page for now.
|
13
|
-
=end
|
9
|
+
# IndexHtmlPlugin is the servlet plugin that is responsible for initializing the "boot-strap page".
|
14
10
|
class IndexHtmlPlugin < Servlet
|
15
11
|
|
16
12
|
def match( uri, method )
|
@@ -31,17 +27,11 @@ class IndexHtmlPlugin < Servlet
|
|
31
27
|
end
|
32
28
|
|
33
29
|
def open
|
34
|
-
#@deps = []
|
35
30
|
@index_html_src = file_read( ::RSence.config[:index_html][:index_tmpl] )
|
36
|
-
# loading_gif = File.read( File.join( @path, 'img/loading.gif' ) )
|
37
|
-
# @loading_gif_id = @plugins[:ticketservices].serve_rsrc( loading_gif, 'image/gif' )
|
38
|
-
# riassence_gif = File.read( File.join( @path, 'img/riassence.gif' ) )
|
39
|
-
# @riassence_gif_id = $TICKETSERVE.serve_rsrc( riassence_gif, 'image/gif' )
|
40
31
|
render_index_html
|
41
32
|
end
|
42
33
|
|
43
34
|
def close
|
44
|
-
# $TICKETSERVE.del_rsrc( @riassence_gif_id )
|
45
35
|
@plugins[:ticket].del_rsrc( @loading_gif_id )
|
46
36
|
end
|
47
37
|
|
@@ -50,8 +40,6 @@ class IndexHtmlPlugin < Servlet
|
|
50
40
|
index_html = @index_html_src.clone
|
51
41
|
|
52
42
|
index_html.gsub!('__DEFAULT_TITLE__',::RSence.config[:index_html][:title])
|
53
|
-
# @index_html.gsub!('__LOADING_GIF_ID__',@loading_gif_id)
|
54
|
-
# @index_html.gsub!('__RIASSENCE_GIF_ID__',@riassence_gif_id)
|
55
43
|
client_rev = @plugins[:client_pkg].client_cache.client_rev
|
56
44
|
index_html.gsub!('__CLIENT_REV__',client_rev)
|
57
45
|
index_html.gsub!('__CLIENT_BASE__',File.join(::RSence.config[:broker_urls][:h],client_rev))
|
@@ -64,16 +52,6 @@ class IndexHtmlPlugin < Servlet
|
|
64
52
|
end
|
65
53
|
index_html.gsub!('__SCRIPT_DEPS__',deps_src)
|
66
54
|
|
67
|
-
# @index_gzip = GZString.new('')
|
68
|
-
# gzwriter = Zlib::GzipWriter.new( @index_gzip, Zlib::BEST_SPEED )
|
69
|
-
# gzwriter.write( @index_html )
|
70
|
-
# gzwriter.close
|
71
|
-
|
72
|
-
# @content_size = @index_html.size
|
73
|
-
# @content_size_gzip = @index_gzip.size
|
74
|
-
|
75
|
-
# @index_date = httime( Time.now )
|
76
|
-
|
77
55
|
return index_html
|
78
56
|
end
|
79
57
|
|
@@ -97,29 +75,20 @@ class IndexHtmlPlugin < Servlet
|
|
97
75
|
)
|
98
76
|
buffer += msg.value_buffer
|
99
77
|
msg.buffer.each do |buffer_item|
|
100
|
-
# if ::RSence.config[:]
|
101
|
-
# buffer.push( "qP(function(){#{buffer_item};console.log(#{buffer_item.to_json});});")
|
102
78
|
buffer.push( "qP(function(){#{buffer_item};});")
|
103
79
|
end
|
104
80
|
ses_key = msg.ses_key
|
105
|
-
# buffer = [ msg.ses_key, msg.value_buffer, msg.buffer ]
|
106
81
|
end
|
107
82
|
buffer.unshift( "COMM.Session.newKey(#{ses_key.to_json});" )
|
108
83
|
buffer.unshift( "COMM.Session.sha_key=#{sha_key.to_json};" )
|
109
84
|
buffer.unshift( "COMM.Session.req_num=#{req_num};" )
|
110
|
-
# buffer.each {|b|puts b}
|
111
|
-
# require 'pp'; pp buffer
|
112
85
|
index_html = render_index_html
|
113
86
|
return index_html.gsub('__STARTUP_SEQUENCE__', buffer.join("\n") )
|
114
87
|
end
|
115
88
|
|
116
89
|
## Outputs a static web page.
|
117
90
|
def get( request, response, ses )
|
118
|
-
# puts "index_html"
|
119
|
-
# index_html = session_index_html( request, response )
|
120
91
|
index_html = render_index_html
|
121
|
-
# index_html = index_html.encode(Encoding::BINARY)
|
122
|
-
|
123
92
|
support_gzip = (request.header.has_key?('accept-encoding') and \
|
124
93
|
request.header['accept-encoding'].include?('gzip')) \
|
125
94
|
and not ::RSence.config[:no_gzip]
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsence
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 961916136
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 0
|
9
9
|
- 0
|
10
|
-
-
|
10
|
+
- 7
|
11
11
|
- pre
|
12
|
-
version: 2.0.0.
|
12
|
+
version: 2.0.0.7.pre
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Riassence Inc.
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2010-05-
|
20
|
+
date: 2010-05-18 00:00:00 +03:00
|
21
21
|
default_executable: rsence
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|