shooting_star 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,20 @@
1
+ *** 3.1.0 / 2007-07-18
2
+ + 1 major enhancement:
3
+ + Added 2 meteor_strike functions 'tuneInOut' and 'tuneOutIn'.
4
+ - Automatic activation/deactivation of flash client.
5
+ - Serialized event execution.
6
+
7
+ + 1 minor enhancement:
8
+ + FileUtil is used instead of `shell command`.
9
+
10
+ + 1 critical bugfix:
11
+ + Fixed broken `shooting_star init'.
12
+
13
+ + 3 minor bugfixes:
14
+ + Corrected initialization order of meteor_strike DOM elements.
15
+ + Managed uncertainty situation of JS/Flash initialization.
16
+ + Applied a patch from Koizuka.
17
+
1
18
  *** 3.0.0 / 2007-06-22
2
19
  + 3 major enhancements:
3
20
  + Added flush client.
@@ -52,21 +52,22 @@ module ShootingStar
52
52
  end
53
53
  # load or create session informations
54
54
  @signature ||= @params['sig']
55
- @channel_path ||= path[1..-1].split('?', 2)[0]
56
- @query = "channel=#{@channel_path}&sig=#{@signature}"
55
+ channel_path = path[1..-1].split('?', 2)[0]
56
+ @channel_path ||= CGI.unescape(channel_path)
57
+ @query = "channel=#{channel_path}&sig=#{@signature}"
57
58
  @type = @params['__t__']
58
59
  # process verb
59
60
  if !@type
60
61
  make_connection(path)
61
62
  else
62
63
  prepare_channel(@channel_path)
64
+ @uid = @@uids[@signature] ||= @params['uid']
65
+ @tag = @@tags[@signature] ||=
66
+ (@params['tag'] || '').split(',').map{|i| CGI.unescape(i)}
63
67
  unless @@servers[@signature] || @type == 'rc'
64
68
  notify(:event => :enter, :uid => @uid, :tag => @tag)
65
69
  log "Connected: #{@uid}"
66
70
  end
67
- @uid = @@uids[@signature] ||= @params['uid']
68
- @tag = @@tags[@signature] ||=
69
- (@params['tag'] || '').split(',').map{|i| CGI.unescape(i)}
70
71
  @executing = @@executings[@signature] ||= Hash.new
71
72
  @@servers[@signature] = self
72
73
  wait_for
@@ -193,15 +194,17 @@ module ShootingStar
193
194
  query += "&" + FormEncoder.encode(params) if params
194
195
  @execution += <<-"EOH"
195
196
  (function(){
197
+ var ms1 = document.getElementById('meteor-strike-1');
198
+ var box = ms1 ? ms1.parentNode : document.body;
196
199
  var iframe = document.createElement('iframe');
197
- var remove = function(){document.body.removeChild(iframe)};
200
+ var remove = function(){box.removeChild(iframe)};
198
201
  var timer = setTimeout(remove, #{sweep_timeout});
199
202
  iframe.onload = function(){
200
203
  clearTimeout(timer);
201
204
  setTimeout(remove, 0);
202
205
  };
203
206
  iframe.src = '#{@params['execute']}/#{id}?#{query}';
204
- document.body.appendChild(iframe);
207
+ box.appendChild(iframe);
205
208
  })();
206
209
  EOH
207
210
  end
data/lib/shooting_star.rb CHANGED
@@ -3,11 +3,12 @@ require 'asteroid'
3
3
  require 'drb/drb'
4
4
  require 'yaml'
5
5
  require 'ftools'
6
+ require 'fileutils'
6
7
  require 'shooting_star/config'
7
8
  require 'shooting_star/shooter'
8
9
 
9
10
  module ShootingStar
10
- VERSION = '3.0.0'
11
+ VERSION = '3.1.0'
11
12
  CONFIG = Config.new(
12
13
  :config => 'config/shooting_star.yml',
13
14
  :pid_file => 'log/shooting_star.pid',
@@ -33,9 +34,9 @@ module ShootingStar
33
34
 
34
35
  # install config file and plugin
35
36
  def self.init
36
- base_dir = CONFIG.directory || `pwd`.chop
37
+ base_dir = CONFIG.directory || FileUtils.pwd
37
38
  config_dir = File.join(base_dir, 'config')
38
- `mkdir -p #{config_dir}` unless File.exist? config_dir
39
+ FileUtils.mkdir_p config_dir unless File.exist?(config_dir)
39
40
  config_file = File.join(config_dir, 'shooting_star.yml')
40
41
  unless File.exist? config_file
41
42
  open(config_file, 'w') do |file|
@@ -46,14 +47,13 @@ module ShootingStar
46
47
  end
47
48
  end
48
49
  log_dir = File.join(base_dir, 'log')
49
- `mkdir -p #{log_dir}` unless File.exist? log_dir
50
+ FileUtils.mkdir_p(log_dir) unless File.exist?(log_dir)
50
51
  plugin_dir = File.join(base_dir, 'vendor/plugins')
51
- `mkdir -p #{plugin_dir}` unless File.exist? plugin_dir
52
+ FileUtils.mkdir_p(plugin_dir) unless File.exist?(plugin_dir)
52
53
  meteor_strike_dir = File.join(plugin_dir, 'meteor_strike')
53
54
  src_dir = File.join(File.dirname(__FILE__),
54
55
  '../vendor/plugins/meteor_strike')
55
- `mkdir -p #{meteor_strike_dir}`
56
- `cp -Rf #{src_dir}/* #{meteor_strike_dir}`
56
+ FileUtils.cp_r(src_dir, plugin_dir)
57
57
  end
58
58
 
59
59
  def self.start(&block)
@@ -4,7 +4,7 @@ class MeteorController < ApplicationController
4
4
  after_filter :notify_execution, :only => [:strike]
5
5
 
6
6
  def strike
7
- @channel = params[:channel].split('/').map{|i| CGI.escape(i)}.join('/')
7
+ @channel = params[:channel]
8
8
  if params[:event].blank?
9
9
  meteor = Meteor.find(params[:id])
10
10
  @javascript = meteor.javascript
@@ -4,9 +4,12 @@
4
4
  (function(){
5
5
  var channel = #{@channel.to_json};
6
6
  var javascript = #{@javascript.to_json};
7
- var meteorStrike = parent.parent.meteorStrike[channel];
8
- if(meteorStrike) meteorStrike.execute(javascript);
9
- else alert('Connection is not established to the ShootingStar server.');
7
+ var execute = function(){
8
+ var meteorStrike = parent.parent.meteorStrike[channel];
9
+ if(meteorStrike) meteorStrike.execute(javascript);
10
+ else setTimeout(execute, 0);
11
+ }
12
+ execute();
10
13
  })();
11
14
  }%>
12
15
  </head>
@@ -36,9 +36,10 @@ module MeteorStrike
36
36
  update_uri = "#{uri}/meteor/update"
37
37
  sig = Meteor.shooter.signature
38
38
  iframe_id = "meteor-strike-#{@meteor_strike}"
39
+ host_port = (server.split(':') << '80')[0..1].join(':')
39
40
  flash_vars = [
40
41
  "channel=#{channel}", "tag=#{tag}", "uid=#{uid}", "sig=#{sig}",
41
- "base_uri=#{uri}", "server=#{server}"].join('&')
42
+ "base_uri=#{uri}", "server=#{host_port}"].join('&')
42
43
  flash_html = flash_tag(flash_vars) unless options[:noflash]
43
44
  <<-"EOH"
44
45
  <div style="position: absolute; top: -99999px; left: -99999px">
@@ -47,7 +48,7 @@ module MeteorStrike
47
48
  action="http://#{shooting_star_uri}">
48
49
  <input name="execute" value="#{uri}/meteor/strike" />
49
50
  <input name="tag" /><input name="uid" /><input name="sig" />
50
- </form>#{flash_html}</div>
51
+ </form>
51
52
  <script type="text/javascript">
52
53
  //<![CDATA[
53
54
  var meteorStrike = meteorStrike || $H();
@@ -76,6 +77,14 @@ module MeteorStrike
76
77
  ms.tuneOut = function(tags){
77
78
  ms.update(UID, Array.prototype.without.apply(TAGS, tags));
78
79
  };
80
+ ms.tuneInOut = function(tagsIn, tagsOut){
81
+ var tags = TAGS.concat(tagsIn || []).uniq();
82
+ ms.update(UID, Array.prototype.without.apply(tags, tagsOut));
83
+ };
84
+ ms.tuneOutIn = function(tagsOut, tagsIn){
85
+ var tags = Array.prototype.without.apply(TAGS, tagsOut);
86
+ ms.update(UID, tags.concat(tagsIn || []).uniq());
87
+ };
79
88
  try{
80
89
  var noflash = #{options[:noflash].to_json};
81
90
  if(noflash || !flashVersion || flashVersion < 6){
@@ -91,7 +100,12 @@ module MeteorStrike
91
100
  }catch(e){}
92
101
  });
93
102
  function meteor_strike_#{@meteor_strike}_DoFSCommand(command, args){
94
- if(command == 'execute') eval(args);
103
+ switch(command){
104
+ case 'execute': eval(args); break;
105
+ case 'event':
106
+ if(args == 'connect') (function(){#{options[:connected]}})();
107
+ break;
108
+ }
95
109
  }
96
110
  if(navigator.appName && navigator.appName.indexOf("Microsoft") != -1 &&
97
111
  navigator.userAgent.indexOf("Windows") != -1 &&
@@ -107,7 +121,7 @@ module MeteorStrike
107
121
  'End Sub', '</script\\>'].join(#{"\n".to_json}));
108
122
  }
109
123
  //]]>
110
- </script>
124
+ </script>#{flash_html}</div>
111
125
  EOH
112
126
  end
113
127
 
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
2
+ rubygems_version: 0.9.3
3
3
  specification_version: 1
4
4
  name: shooting_star
5
5
  version: !ruby/object:Gem::Version
6
- version: 3.0.0
7
- date: 2007-06-22 00:00:00 +09:00
6
+ version: 3.1.0
7
+ date: 2007-07-18 00:00:00 +09:00
8
8
  summary: Our goal is development of practical comet server which will be achieving over 100,000 simultaneous connections per host. On this purpose, we abandon portability and use system calls depending on particular OS such as epoll and kqueue.
9
9
  require_paths:
10
10
  - lib
@@ -93,8 +93,10 @@ rdoc_options:
93
93
  - --exclude
94
94
  - ext/asteroid
95
95
  - README.txt
96
- extra_rdoc_files: []
97
-
96
+ extra_rdoc_files:
97
+ - History.txt
98
+ - Manifest.txt
99
+ - README.txt
98
100
  executables:
99
101
  - shooting_star
100
102
  extensions:
@@ -118,5 +120,5 @@ dependencies:
118
120
  requirements:
119
121
  - - ">="
120
122
  - !ruby/object:Gem::Version
121
- version: 1.2.0
123
+ version: 1.2.1
122
124
  version: