Commit 9947112d authored by nanahira's avatar nanahira

Merge branch 'plugins' into mc

parents 2e38ee98 e8ef0195
# ignore
jsconfig.json
coffeelint.json
.vscode/
password.json
config.*.json
config.user.bak
/bak
/config
/ygopro
/windbot
/decks
/decks_save*
/replays
/node_modules
/ssl
/ygosrv233
/challonge
/logs
/plugins
test*
*.heapsnapshot
*.tmp
*.bak
*.log
*.map
Thumbs.db
ehthumbs.db
Desktop.ini
$RECYCLE.BIN/
.DS_Store
.git* .git*
.dockerignore .dockerignore
Dockerfile* Dockerfile*
......
...@@ -19,6 +19,7 @@ config.user.bak ...@@ -19,6 +19,7 @@ config.user.bak
/ygosrv233 /ygosrv233
/challonge /challonge
/logs /logs
/plugins
test* test*
*.heapsnapshot *.heapsnapshot
......
This diff is collapsed.
This diff is collapsed.
...@@ -37,26 +37,55 @@ for name, declaration of structs_declaration ...@@ -37,26 +37,55 @@ for name, declaration of structs_declaration
#消息跟踪函数 需要重构, 另暂时只支持异步, 同步没做. #消息跟踪函数 需要重构, 另暂时只支持异步, 同步没做.
@stoc_follows = {} @stoc_follows = {}
@stoc_follows_before = {}
@stoc_follows_after = {}
@ctos_follows = {} @ctos_follows = {}
@ctos_follows_before = {}
@ctos_follows_after = {}
@replace_proto = (proto, tp) ->
if typeof(proto) != "string"
return proto
changed_proto = proto
for key, value of @constants[tp]
if value == proto
changed_proto = key
break
throw "unknown proto" if !@constants[tp][changed_proto]
return changed_proto
@stoc_follow = (proto, synchronous, callback)-> @stoc_follow = (proto, synchronous, callback)->
if typeof proto == 'string' changed_proto = @replace_proto(proto, "STOC")
for key, value of @constants.STOC @stoc_follows[changed_proto] = {callback: callback, synchronous: synchronous}
if value == proto return
proto = key @stoc_follow_before = (proto, synchronous, callback)->
break changed_proto = @replace_proto(proto, "STOC")
throw "unknown proto" if !@constants.STOC[proto] if !@stoc_follows_before[changed_proto]
@stoc_follows[proto] = {callback: callback, synchronous: synchronous} @stoc_follows_before[changed_proto] = []
@stoc_follows_before[changed_proto].push({callback: callback, synchronous: synchronous})
return
@stoc_follow_after = (proto, synchronous, callback)->
changed_proto = @replace_proto(proto, "STOC")
if !@stoc_follows_after[changed_proto]
@stoc_follows_after[changed_proto] = []
@stoc_follows_after[changed_proto].push({callback: callback, synchronous: synchronous})
return return
@ctos_follow = (proto, synchronous, callback)-> @ctos_follow = (proto, synchronous, callback)->
if typeof proto == 'string' changed_proto = @replace_proto(proto, "CTOS")
for key, value of @constants.CTOS @ctos_follows[changed_proto] = {callback: callback, synchronous: synchronous}
if value == proto return
proto = key @ctos_follow_before = (proto, synchronous, callback)->
break changed_proto = @replace_proto(proto, "CTOS")
throw "unknown proto" if !@constants.CTOS[proto] if !@ctos_follows_before[changed_proto]
@ctos_follows[proto] = {callback: callback, synchronous: synchronous} @ctos_follows_before[changed_proto] = []
@ctos_follows_before[changed_proto].push({callback: callback, synchronous: synchronous})
return
@ctos_follow_after = (proto, synchronous, callback)->
changed_proto = @replace_proto(proto, "CTOS")
if !@ctos_follows_after[changed_proto]
@ctos_follows_after[changed_proto] = []
@ctos_follows_after[changed_proto].push({callback: callback, synchronous: synchronous})
return return
#消息发送函数,至少要把俩合起来.... #消息发送函数,至少要把俩合起来....
@stoc_send = (socket, proto, info)-> @stoc_send = (socket, proto, info)->
...@@ -171,4 +200,4 @@ for name, declaration of structs_declaration ...@@ -171,4 +200,4 @@ for name, declaration of structs_declaration
if client if client
client.system_kicked = true client.system_kicked = true
client.destroy() client.destroy()
return return
\ No newline at end of file
...@@ -58,50 +58,102 @@ ...@@ -58,50 +58,102 @@
this.stoc_follows = {}; this.stoc_follows = {};
this.stoc_follows_before = {};
this.stoc_follows_after = {};
this.ctos_follows = {}; this.ctos_follows = {};
this.stoc_follow = function(proto, synchronous, callback) { this.ctos_follows_before = {};
var key, ref, value;
if (typeof proto === 'string') { this.ctos_follows_after = {};
ref = this.constants.STOC;
for (key in ref) { this.replace_proto = function(proto, tp) {
value = ref[key]; var changed_proto, key, ref, value;
if (value === proto) { if (typeof proto !== "string") {
proto = key; return proto;
break; }
} changed_proto = proto;
} ref = this.constants[tp];
if (!this.constants.STOC[proto]) { for (key in ref) {
throw "unknown proto"; value = ref[key];
if (value === proto) {
changed_proto = key;
break;
} }
} }
this.stoc_follows[proto] = { if (!this.constants[tp][changed_proto]) {
throw "unknown proto";
}
return changed_proto;
};
this.stoc_follow = function(proto, synchronous, callback) {
var changed_proto;
changed_proto = this.replace_proto(proto, "STOC");
this.stoc_follows[changed_proto] = {
callback: callback, callback: callback,
synchronous: synchronous synchronous: synchronous
}; };
}; };
this.ctos_follow = function(proto, synchronous, callback) { this.stoc_follow_before = function(proto, synchronous, callback) {
var key, ref, value; var changed_proto;
if (typeof proto === 'string') { changed_proto = this.replace_proto(proto, "STOC");
ref = this.constants.CTOS; if (!this.stoc_follows_before[changed_proto]) {
for (key in ref) { this.stoc_follows_before[changed_proto] = [];
value = ref[key];
if (value === proto) {
proto = key;
break;
}
}
if (!this.constants.CTOS[proto]) {
throw "unknown proto";
}
} }
this.ctos_follows[proto] = { this.stoc_follows_before[changed_proto].push({
callback: callback,
synchronous: synchronous
});
};
this.stoc_follow_after = function(proto, synchronous, callback) {
var changed_proto;
changed_proto = this.replace_proto(proto, "STOC");
if (!this.stoc_follows_after[changed_proto]) {
this.stoc_follows_after[changed_proto] = [];
}
this.stoc_follows_after[changed_proto].push({
callback: callback,
synchronous: synchronous
});
};
this.ctos_follow = function(proto, synchronous, callback) {
var changed_proto;
changed_proto = this.replace_proto(proto, "CTOS");
this.ctos_follows[changed_proto] = {
callback: callback, callback: callback,
synchronous: synchronous synchronous: synchronous
}; };
}; };
this.ctos_follow_before = function(proto, synchronous, callback) {
var changed_proto;
changed_proto = this.replace_proto(proto, "CTOS");
if (!this.ctos_follows_before[changed_proto]) {
this.ctos_follows_before[changed_proto] = [];
}
this.ctos_follows_before[changed_proto].push({
callback: callback,
synchronous: synchronous
});
};
this.ctos_follow_after = function(proto, synchronous, callback) {
var changed_proto;
changed_proto = this.replace_proto(proto, "CTOS");
if (!this.ctos_follows_after[changed_proto]) {
this.ctos_follows_after[changed_proto] = [];
}
this.ctos_follows_after[changed_proto].push({
callback: callback,
synchronous: synchronous
});
};
this.stoc_send = function(socket, proto, info) { this.stoc_send = function(socket, proto, info) {
var buffer, header, key, ref, struct, value; var buffer, header, key, ref, struct, value;
if (socket.closed) { if (socket.closed) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment