dango_generator 0.2.6 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/dango_generator.rb CHANGED
@@ -40,14 +40,14 @@ class DangoGenerator < Rails::Generator::NamedBase
40
40
  m.template "dango/client_swf/DangoConfig.as" , "dango/client_swf/DangoConfig.as"
41
41
 
42
42
  # dangoコンフィグ
43
- m.directory 'dango/config'
43
+ m.directory 'config/dango'
44
44
  %w(
45
45
  development.yml
46
46
  test.yml
47
47
  production.yml
48
48
  system_message.yml
49
49
  ).each do |as3_file|
50
- m.template "dango/config/#{as3_file}", "dango/config/#{as3_file}"
50
+ m.template "config/dango/#{as3_file}", "config/dango/#{as3_file}"
51
51
  end
52
52
 
53
53
  # dangoのas3ライブラリ
@@ -0,0 +1,7 @@
1
+ # == About dango.rb
2
+ #
3
+ # show http://dango-net.org/page/demo
4
+ #
5
+
6
+ require "dango_generator/version.rb"
7
+
@@ -27,6 +27,8 @@ package org.rubyforge.dango {
27
27
  private var socket:Socket; //ソケット
28
28
  private var dispatcher:EventDispatcher; // Event送出用
29
29
 
30
+ private var default_encode_type:uint = 0; // 送信データのエンコードタイプはJSON
31
+
30
32
  private var is_debug:Boolean; // Debugモードかどうかのフラグ
31
33
  private var is_connect:Boolean = false; // 接続完了しているかどうか
32
34
 
@@ -85,12 +87,17 @@ package org.rubyforge.dango {
85
87
  // var policy_file_port:uint = config.policy_file_port;
86
88
  var policy_file_path:String = config.policy_file_path;
87
89
 
90
+ if(is_debug){ trace("flash player: " + Capabilities.version); }
91
+ if(is_debug){ trace("isDebugger: " + Capabilities.isDebugger); }
92
+ if(is_debug){ trace("language: " + Capabilities.language); }
93
+ if(is_debug){ trace("os: " + Capabilities.os); }
94
+ if(is_debug){ trace("frame_rate: " + frame_rate); }
88
95
 
89
96
  // Event送出用
90
97
  dispatcher = new EventDispatcher(this);
91
98
 
92
99
  // Security.sandboxType
93
- trace("Security.sandboxType:" + Security.sandboxType);
100
+ if(is_debug){ trace("Security.sandboxType:" + Security.sandboxType); }
94
101
 
95
102
  // policy_file
96
103
  // if(!policy_file_protocol){ policy_file_protocol = "http" };
@@ -118,17 +125,17 @@ package org.rubyforge.dango {
118
125
  // url_load_policy_file = "xmlsocket://" + server_host + ":" + server_port;
119
126
  // url_load_policy_file = "http://aiarebaba.hi-fi-net.com/crossdomain.xml";
120
127
  url_load_policy_file = "http://" + server_host + policy_file_path;
121
- trace("url_load_policy_file=" + url_load_policy_file);
128
+ if(is_debug){ trace("url_load_policy_file=" + url_load_policy_file); }
122
129
  Security.loadPolicyFile(url_load_policy_file);
123
130
  }
124
131
 
125
132
  // 接続
126
133
  try{
127
- trace("connectiong... host=" + server_host + " port=" + server_port);
134
+ if(is_debug){ trace("connectiong... host=" + server_host + " port=" + server_port); }
128
135
  socket.connect(server_host, server_port);
129
- trace("connected host=" + server_host + " port=" + server_port);
136
+ if(is_debug){ trace("connected host=" + server_host + " port=" + server_port); }
130
137
  } catch(err:Error){
131
- trace("connect error err=" + err + " name=" + err.name + " message=" + err.message);
138
+ if(is_debug){ trace("connect error err=" + err + " name=" + err.name + " message=" + err.message); }
132
139
  return(void);
133
140
  }
134
141
 
@@ -283,7 +290,7 @@ package org.rubyforge.dango {
283
290
 
284
291
  // 前回から時間がかかりすぎている(処理落ちしかけている場合は)スキップ
285
292
  var start_date:Date = new Date();
286
- if(recv_do_last_date.time > start_date.time - (Number(recv_do_timer_msec) * 1.3)){
293
+ if(recv_do_last_date.time > start_date.time - (Number(recv_do_timer_msec) * 1.4)){
287
294
  if(recv_wait_do_cache.length > 0){
288
295
  var recv_arr:Array = recv_wait_do_cache.shift();
289
296
  var notice_name:String = recv_arr[0];
@@ -299,6 +306,7 @@ package org.rubyforge.dango {
299
306
  if(is_debug){ trace("DangoClientFramework:dispatchEvent:dango_" + notice_name + " server_time=" + server_time); }
300
307
  this.dispatchEvent(new DangoReceiveEvent("dango__before_filter", recv_data, count_no));
301
308
  this.dispatchEvent(new DangoReceiveEvent("dango_" + notice_name, recv_data, count_no));
309
+ this.dispatchEvent(new DangoReceiveEvent("dango__after_filter", recv_data, count_no));
302
310
  }
303
311
  }
304
312
  }
@@ -403,7 +411,7 @@ package org.rubyforge.dango {
403
411
  public function send_data_to_server( send_obj:Array ):void {
404
412
  // if(is_debug){ trace("DangoClientFramework:send_data_to_server:send_obj=" + ObjectUtil.toString(send_obj)); }
405
413
 
406
- var type:int = 0;
414
+ var encode_type:uint = default_encode_type;
407
415
 
408
416
  // データが空ならJSONencodeしない
409
417
  var send_obj_str:String;
@@ -415,11 +423,11 @@ package org.rubyforge.dango {
415
423
 
416
424
  var send_obj_size:int = DangoUtil.string_byte_length(send_obj_str);
417
425
 
418
- // if(is_debug){ trace("DangoClientFramework:send:" + type + ":" + send_obj_size + ":" + send_obj_str); }
426
+ // if(is_debug){ trace("DangoClientFramework:send:" + encode_type + ":" + send_obj_size + ":" + send_obj_str); }
419
427
 
420
428
  // 長さ送信
421
429
  var byte_array:ByteArray = new ByteArray;
422
- byte_array.writeByte(type);
430
+ byte_array.writeByte(encode_type);
423
431
  byte_array.writeUnsignedInt(send_obj_size);
424
432
 
425
433
  socket.writeBytes(byte_array, 0, 5);
@@ -469,7 +477,7 @@ package org.rubyforge.dango {
469
477
  return([]);
470
478
  }
471
479
 
472
- var type:int = byte_array_size.readByte();
480
+ var encode_type:int = byte_array_size.readByte();
473
481
  recv_not_yet_size = byte_array_size.readUnsignedInt();
474
482
  var crlf:String = byte_array.readUTFBytes(1);
475
483
  byte_read_size -= 6;
File without changes
@@ -3,28 +3,37 @@
3
3
  puts "Booting DangoServer..."
4
4
  require File.dirname(__FILE__) + '/../config/boot'
5
5
 
6
- require "yaml"
7
- require "getoptlong"
8
-
9
- # 環境によるコンフィグ読み込み
10
- env = ENV['RAILS_ENV'] || 'development'
11
- env = ARGV[0] if ARGV[0]
12
- config = YAML.load(open("dango/config/#{env}.yml", "rb"){|fh| fh.read})
13
- puts "environment=#{env}"
6
+ CanReadOptionServer = %w(host max_connections log_file log_level log_max_size log_shift_age gserver_log_file)
7
+ CanReadOptionNetwork = %w(host port)
14
8
 
15
- # コマンドラインオプション取得
9
+ # コマンドラインオプション取得とコンフィグの上書き
10
+ require 'getoptlong.rb'
16
11
  opt_parser = GetoptLong.new
17
12
 
18
- # コマンドラインオプションによるコンフィグの上書き
19
- options_arr = ["dango"]
20
- config["server"].each{|k, v| options_arr.push("server:#{k}") }
21
- config["network"].each{|k, v| options_arr.push("network:#{k}") }
22
- options_set_options = options_arr.uniq.collect{|o| ["--#{o}", GetoptLong::OPTIONAL_ARGUMENT]}
13
+ options_arr = []
14
+ #config["server"].each{|k, v| options_arr.push("server:#{k}") }
15
+ #config["network"].each{|k, v| options_arr.push("network:#{k}") }
16
+ CanReadOptionServer.each{|k, v| options_arr.push("server:#{k}") }
17
+ CanReadOptionNetwork.each{|k, v| options_arr.push("network:#{k}") }
18
+
19
+ options_set_options = options_arr.uniq.collect{|o| ["--#{o}", GetoptLong::OPTIONAL_ARGUMENT] }
20
+ options_set_options << ["--dango", GetoptLong::OPTIONAL_ARGUMENT]
21
+ options_set_options << ["-e", GetoptLong::OPTIONAL_ARGUMENT]
22
+
23
23
  opt_parser.set_options(*options_set_options)
24
24
 
25
25
  start_options = {}
26
26
  opt_parser.each_option{|n,a| start_options[n] = a}
27
27
 
28
+
29
+ # 環境によるコンフィグ読み込み
30
+ require "yaml"
31
+ ENV['RAILS_ENV'] = start_options['-e'] if start_options['-e']
32
+ env = ENV['RAILS_ENV'] || 'development'
33
+ config_file = "config/dango/#{env}.yml"
34
+ puts "loading config file:#{config_file}"
35
+ config = YAML.load(open(config_file, "rb"){|fh| fh.read})
36
+
28
37
  # rubygems
29
38
  require 'rubygems'
30
39
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dango_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keisuke Minami
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-06-15 00:00:00 +09:00
12
+ date: 2008-06-20 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -27,6 +27,7 @@ files:
27
27
  - README.txt
28
28
  - LICENSE
29
29
  - dango_generator.rb
30
+ - lib/dango_generator.rb
30
31
  - templates/script/dango_server
31
32
  - templates/lib/dango_monitor_client.rb
32
33
  - templates/lib/dango_tester_client.rb
@@ -34,10 +35,10 @@ files:
34
35
  - templates/public/crossdomain.xml
35
36
  - templates/dango/server/99_dango_server.rb
36
37
  - templates/dango/client_swf/DangoConfig.as
37
- - templates/dango/config/development.yml
38
- - templates/dango/config/test.yml
39
- - templates/dango/config/production.yml
40
- - templates/dango/config/system_message.yml
38
+ - templates/config/dango/development.yml
39
+ - templates/config/dango/test.yml
40
+ - templates/config/dango/production.yml
41
+ - templates/config/dango/system_message.yml
41
42
  - templates/as3/org/rubyforge/dango/DangoClientFramework.as
42
43
  - templates/as3/org/rubyforge/dango/DangoError.as
43
44
  - templates/as3/org/rubyforge/dango/DangoErrorCode.as