dango_generator 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/templates/as3/org/rubyforge/dango/DangoAS3Mode.as +9 -0
- data/templates/as3/org/rubyforge/dango/DangoClientFramework.as +2 -10
- data/templates/as3/org/rubyforge/dango/DangoUtil.as +46 -1
- data/templates/sample_as3mode/dango/client_swf/bin-debug/sample_as3mode.swf +0 -0
- data/templates/sample_as3mode/dango/client_swf/src/sample_as3mode.mxml +23 -2
- data/templates/sample_as3mode/dango/server/99_dango_server.rb +16 -3
- data/templates/sample_servermode_chat/dango/client_swf/bin-debug/sample_servermode_chat.swf +0 -0
- metadata +3 -3
@@ -96,6 +96,15 @@ package org.rubyforge.dango {
|
|
96
96
|
private function dango_notice_current_sids(evt:DangoReceiveEvent):void {
|
97
97
|
var ret:Object = evt.receive_data;
|
98
98
|
all_sid_list = ret["sids"];
|
99
|
+
|
100
|
+
var recv_data:Object = {};
|
101
|
+
recv_data["_from_sid"] = ret["_from_sid"]
|
102
|
+
if(ret["is_connect"]){
|
103
|
+
this.dispatchEvent(new DangoAS3ModeReceiveEvent("dango__other_connect", recv_data));
|
104
|
+
}
|
105
|
+
if(ret["is_close"]){
|
106
|
+
this.dispatchEvent(new DangoAS3ModeReceiveEvent("dango__other_close", recv_data));
|
107
|
+
}
|
99
108
|
}
|
100
109
|
|
101
110
|
|
@@ -595,6 +595,7 @@ package org.rubyforge.dango {
|
|
595
595
|
* @param evt:DangoReceiveEvent
|
596
596
|
* @return void
|
597
597
|
protected function dango__connect(evt:Object):void {
|
598
|
+
trace("DangoClientFramework:receive dango__connect");
|
598
599
|
}
|
599
600
|
*/
|
600
601
|
|
@@ -606,18 +607,9 @@ package org.rubyforge.dango {
|
|
606
607
|
* @param evt:DangoReceiveEvent
|
607
608
|
* @return void
|
608
609
|
protected function dango__after_filter(evt:Object):void {
|
610
|
+
trace("DangoClientFramework:receive dango__after_filter");
|
609
611
|
}
|
610
612
|
*/
|
611
613
|
|
612
|
-
/**
|
613
|
-
* dango__after_filter の雛形
|
614
|
-
* すべてのdango通知の前処理用のメソッド
|
615
|
-
* オーバーライドして使うもの
|
616
|
-
*
|
617
|
-
* @param evt:DangoReceiveEvent
|
618
|
-
* @return void
|
619
|
-
protected function dango__after_filter(evt:Object):void {
|
620
|
-
}
|
621
|
-
*/
|
622
614
|
}
|
623
615
|
}
|
@@ -143,6 +143,51 @@ package org.rubyforge.dango {
|
|
143
143
|
var result:Object = byta.readObject();
|
144
144
|
return result;
|
145
145
|
}
|
146
|
-
|
146
|
+
|
147
|
+
/**
|
148
|
+
* オブジェクトを読みやすい形式に変換
|
149
|
+
*
|
150
|
+
* @param obj 元になるObject
|
151
|
+
* @return String
|
152
|
+
*/
|
153
|
+
public static function toString(obj:Object):String {
|
154
|
+
var str:String = parse_obj(obj, 0);
|
155
|
+
return str;
|
156
|
+
}
|
157
|
+
|
158
|
+
private static function parse_obj(obj:Object, indent:uint):String{
|
159
|
+
var str:String = "";
|
160
|
+
|
161
|
+
if(obj == null){
|
162
|
+
str += indent_str(indent) + "null" + "\n";
|
163
|
+
} else {
|
164
|
+
var type:String = typeof(obj);
|
165
|
+
if(type == "boolean" || type == "number"){
|
166
|
+
str += indent_str(indent) + obj.toString() + "\n";
|
167
|
+
|
168
|
+
} else if(type == "string"){
|
169
|
+
str += indent_str(indent) + "\"" + obj.toString() + "\"" + "\n";
|
170
|
+
|
171
|
+
} else if(type == "object"){
|
172
|
+
for(var i:String in obj) {
|
173
|
+
str += indent_str(indent) + i + "=>\n";
|
174
|
+
str += parse_obj(obj[i], indent + 1);
|
175
|
+
}
|
176
|
+
|
177
|
+
} else {
|
178
|
+
str += indent_str(indent) + "(" + type + ")" + "\n";
|
179
|
+
}
|
180
|
+
}
|
181
|
+
return str;
|
182
|
+
}
|
183
|
+
|
184
|
+
private static function indent_str(indent:uint):String{
|
185
|
+
var str:String = "";
|
186
|
+
for (var j:uint = 0; j < indent * 2; j++) {
|
187
|
+
str += " ";
|
188
|
+
}
|
189
|
+
return str;
|
190
|
+
}
|
191
|
+
|
147
192
|
}
|
148
193
|
}
|
Binary file
|
@@ -27,6 +27,12 @@
|
|
27
27
|
// 接続完了時のイベントリスナ定義
|
28
28
|
dango_as3mode.addEventListener("dango__connect", dango__connect);
|
29
29
|
|
30
|
+
// 他人が接続した時のイベントリスナ定義
|
31
|
+
dango_as3mode.addEventListener("dango__other_connect", dango__other_connect);
|
32
|
+
|
33
|
+
// 他人が切断した時のイベントリスナ定義
|
34
|
+
dango_as3mode.addEventListener("dango__other_close", dango__other_close);
|
35
|
+
|
30
36
|
// 他のクライアントからデータを受け取った時のイベントリスナ定義
|
31
37
|
dango_as3mode.addEventListener("dango_as3mode_receive", dango_as3mode_receive);
|
32
38
|
}
|
@@ -34,17 +40,32 @@
|
|
34
40
|
// dangoフレームワークでエラーが起きた場合は接続エラーをtraceに出力
|
35
41
|
private function connection_error(evt:DangoErrorEvent):void {
|
36
42
|
trace("FrameworkError:code=" + evt.code + ":message=" + evt.message);
|
43
|
+
log.text += "Error code=" + evt.code + ":message=" + evt.message + "\n"
|
37
44
|
}
|
38
45
|
|
39
46
|
// 接続完了時に、テキストエリアに「接続完了」と表示します。
|
40
47
|
private function dango__connect(evt:DangoAS3ModeReceiveEvent):void{
|
41
|
-
log.text += "接続完了" + dango_as3mode.sid + "\n"
|
48
|
+
log.text += "接続完了 sid=" + dango_as3mode.sid + "\n"
|
49
|
+
}
|
50
|
+
|
51
|
+
// 他人の接続時に、テキストエリアに「sidの接続」と表示します。
|
52
|
+
private function dango__other_connect(evt:DangoAS3ModeReceiveEvent):void{
|
53
|
+
log.text += "sid=" + evt.receive_data["_from_sid"] + "の接続\n"
|
54
|
+
}
|
55
|
+
|
56
|
+
// 他人の切断時に、テキストエリアに「sidの切断」と表示します。
|
57
|
+
private function dango__other_close(evt:DangoAS3ModeReceiveEvent):void{
|
58
|
+
log.text += "sid=" + evt.receive_data["_from_sid"] + "の切断\n"
|
42
59
|
}
|
43
60
|
|
44
61
|
// メッセージを受け取った時に、テキストエリアに受け取ったメッセージを表示します。
|
45
62
|
private function dango_as3mode_receive(evt:DangoAS3ModeReceiveEvent):void{
|
46
63
|
trace("dango_as3mode_receive");
|
47
|
-
log.text += evt.receive_data["chat"] + "\n"
|
64
|
+
log.text += "sid=" + evt.receive_data["_from_sid"] + ":" +evt.receive_data["chat"] + "\n";
|
65
|
+
if(!evt.receive_data["is_return"] && dango_as3mode.sid != evt.receive_data["_from_sid"]){
|
66
|
+
dango_as3mode.send_object({"chat":"受け取ったよ!", "is_return":true},
|
67
|
+
[evt.receive_data["_from_sid"]]);
|
68
|
+
}
|
48
69
|
}
|
49
70
|
|
50
71
|
// ボタンをクリックした時に全クライアントにchatメッセージを送信します
|
@@ -18,7 +18,11 @@ class DangoServer < DangoServerFramework
|
|
18
18
|
shared.commit(sids)
|
19
19
|
end
|
20
20
|
|
21
|
-
send_obj = {
|
21
|
+
send_obj = { # 全員に現在のsid一覧を送る
|
22
|
+
:sids => current_sids,
|
23
|
+
:is_connect => true,
|
24
|
+
:_from_sid => session[:sid],
|
25
|
+
}
|
22
26
|
send_notice(:notice_current_sids, current_sids, send_obj)
|
23
27
|
end
|
24
28
|
|
@@ -31,7 +35,11 @@ class DangoServer < DangoServerFramework
|
|
31
35
|
shared.commit(sids)
|
32
36
|
end
|
33
37
|
|
34
|
-
send_obj = {
|
38
|
+
send_obj = { # 全員に現在のsid一覧を送る
|
39
|
+
:sids => current_sids,
|
40
|
+
:is_close => true,
|
41
|
+
:_from_sid => session[:sid],
|
42
|
+
}
|
35
43
|
send_notice(:notice_current_sids, current_sids, send_obj)
|
36
44
|
end
|
37
45
|
|
@@ -40,11 +48,16 @@ class DangoServer < DangoServerFramework
|
|
40
48
|
send_obj = rec_obj["object"]
|
41
49
|
to_sids = rec_obj["sids"]
|
42
50
|
current_sids = shared[:sids]
|
51
|
+
|
52
|
+
logger.warn "send_obj=#{send_obj.inspect}"
|
53
|
+
logger.warn "to_sids=#{to_sids.inspect}"
|
54
|
+
logger.warn "current_sids=#{current_sids.inspect}"
|
55
|
+
|
43
56
|
if to_sids.is_a?(Array)
|
44
57
|
if to_sids == []
|
45
58
|
to_sids = current_sids
|
46
59
|
else
|
47
|
-
to_sids.delete_if {|sid| !current_sids.include?(
|
60
|
+
to_sids.delete_if {|sid| !current_sids.include?(sid) }
|
48
61
|
end
|
49
62
|
send_obj[:_from_sid] = session[:sid]
|
50
63
|
send_notice(:notice_send_object, to_sids, send_obj)
|
Binary file
|
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.5.
|
4
|
+
version: 0.5.2
|
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-12-
|
12
|
+
date: 2008-12-15 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
132
|
requirements: []
|
133
133
|
|
134
134
|
rubyforge_project: dango
|
135
|
-
rubygems_version: 1.
|
135
|
+
rubygems_version: 1.3.1
|
136
136
|
signing_key:
|
137
137
|
specification_version: 2
|
138
138
|
summary: dango_generator
|