Commit 7d1abf01 authored by IamI's avatar IamI

Fix

parent 884a8b23
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
"timeInterval": 10000, "timeInterval": 10000,
"athleticTrueSkillGate": 0.4, "athleticTrueSkillGate": 0.4,
"entertainExpGate": 100, "entertainExpGate": 100,
"atheleticPtGate": [350, 50, 500] "atheleticPtGate": [350, 50, 500],
"longestGameTime": 7200000,
"reconnect": "reconnect"
} }
} }
...@@ -217,6 +217,7 @@ let pair = function (userARes, userBRes, serverName) { ...@@ -217,6 +217,7 @@ let pair = function (userARes, userBRes, serverName) {
"password": password "password": password
}); });
playingPlayerPool.set(client.username, result); playingPlayerPool.set(client.username, result);
setTimeout(timeoutUser, config.match.longestMatchTime, client.username);
client.writeHead(200, {'Content-Type': 'application/json', 'Cache-Control': 'no-cache'}); client.writeHead(200, {'Content-Type': 'application/json', 'Cache-Control': 'no-cache'});
client.end(result); client.end(result);
} }
...@@ -288,6 +289,12 @@ let finishUser = function (json) { ...@@ -288,6 +289,12 @@ let finishUser = function (json) {
} }
}; };
// 当超过时间,而 srvpro 从未通知基本服务器游戏已结束时
let timeoutUser = function(user) {
if (playingPlayerPool.delete(user))
localLog("With timeout, user is seen as had left the game: " + user);
};
// 计算预期时间 // 计算预期时间
let calculatePredictedTime = function() { let calculatePredictedTime = function() {
if (entertainRequestCountInTime == 0) if (entertainRequestCountInTime == 0)
...@@ -318,9 +325,17 @@ let matchResponse = function(req, res) { ...@@ -318,9 +325,17 @@ let matchResponse = function(req, res) {
} }
// 检定是否掉线重连 // 检定是否掉线重连
if (playingPlayerPool.has(username)) { if (playingPlayerPool.has(username)) {
res.writeHead(200, {'Content-Type': 'application/json', 'Cache-Control': 'no-cache'}); switch (config.match.reconnect) {
res.end(playingPlayerPool.get(username)); case "reconnect":
return; res.writeHead(200, {'Content-Type': 'application/json', 'Cache-Control': 'no-cache'});
res.end(playingPlayerPool.get(username));
return;
case "drop":
rejectUser(res);
return;
default:
break; // 什么都不做,继续加入匹配池。
}
} }
let arg = url.parse(req.url, true).query; let arg = url.parse(req.url, true).query;
if (!arg.arena) arg.arena = 'entertain'; if (!arg.arena) arg.arena = 'entertain';
......
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