api 锁修改,一键接取悬赏
This commit is contained in:
parent
826840455c
commit
ecc17a22a9
@ -1,9 +1,10 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import { HeroFun } from '../../public/hero';
|
import { addGameLog } from "../../gameLog";
|
||||||
import { XstaskFun } from '../../public/xstask';
|
import {HeroFun} from '../../public/hero';
|
||||||
import { ReqOnekeyReceive, ResOnekeyReceive } from "../../shared/protocols/xstask/PtlOnekeyReceive";
|
import {XstaskFun} from '../../public/xstask';
|
||||||
import { HeroShared } from '../../shared/public/hero';
|
import {ReqOnekeyReceive, ResOnekeyReceive} from "../../shared/protocols/xstask/PtlOnekeyReceive";
|
||||||
import { HongDianChange } from "../hongdian/fun";
|
import {HeroShared} from '../../shared/public/hero';
|
||||||
|
import {HongDianChange} from "../hongdian/fun";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqOnekeyReceive, ResOnekeyReceive>) {
|
export default async function (call: ApiCall<ReqOnekeyReceive, ResOnekeyReceive>) {
|
||||||
|
|
||||||
@ -33,7 +34,9 @@ export default async function (call: ApiCall<ReqOnekeyReceive, ResOnekeyReceive>
|
|||||||
if (heroList.length != heroIds.length) return call.error(globalThis.lng.xstask_6);
|
if (heroList.length != heroIds.length) return call.error(globalThis.lng.xstask_6);
|
||||||
|
|
||||||
let change: ResOnekeyReceive = {};
|
let change: ResOnekeyReceive = {};
|
||||||
|
let lockNum = event?.receiveNum || 0
|
||||||
for (let receive of args) {
|
for (let receive of args) {
|
||||||
|
if (lockNum >= 8) continue
|
||||||
let task = taskList.find(task => task._id == receive._id);
|
let task = taskList.find(task => task._id == receive._id);
|
||||||
let taskConf = G.gc.xstask[task.taskId];
|
let taskConf = G.gc.xstask[task.taskId];
|
||||||
|
|
||||||
@ -43,8 +46,9 @@ export default async function (call: ApiCall<ReqOnekeyReceive, ResOnekeyReceive>
|
|||||||
let star = heros.map(h => G.gc.hero[h.heroId].star).reduce((a, b) => a + b);
|
let star = heros.map(h => G.gc.hero[h.heroId].star).reduce((a, b) => a + b);
|
||||||
if (star < taskConf.needStar) return call.error(globalThis.lng.xstask_8);
|
if (star < taskConf.needStar) return call.error(globalThis.lng.xstask_8);
|
||||||
|
|
||||||
change[receive._id] = { time: G.time, heros: receive.heroIds };
|
change[receive._id] = {time: G.time, heros: receive.heroIds};
|
||||||
XstaskFun.receiveNum(call.uid)
|
XstaskFun.receiveNum(call.uid)
|
||||||
|
lockNum += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.entries(change).forEach(([k, v]) => {
|
Object.entries(change).forEach(([k, v]) => {
|
||||||
@ -53,4 +57,6 @@ export default async function (call: ApiCall<ReqOnekeyReceive, ResOnekeyReceive>
|
|||||||
HongDianChange.sendChangeKey(call.uid, ['xstaskhd', 'huodonghd']);
|
HongDianChange.sendChangeKey(call.uid, ['xstaskhd', 'huodonghd']);
|
||||||
|
|
||||||
call.succ(change);
|
call.succ(change);
|
||||||
|
|
||||||
|
addGameLog(call.uid, "_onekeyReceive", {}, change)
|
||||||
}
|
}
|
@ -6,7 +6,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key":"got_jinbi",
|
"key":"got_jinbi",
|
||||||
"limit":200000000,
|
"limit":2000000000,
|
||||||
"tips":"jinbi获取达到20亿"
|
"tips":"jinbi获取达到20亿"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
20
src/setWs.ts
20
src/setWs.ts
@ -13,7 +13,7 @@ import {player} from './shared/protocols/user/type';
|
|||||||
import {unQueueByConn} from './api_s2c/user/ApiLogin';
|
import {unQueueByConn} from './api_s2c/user/ApiLogin';
|
||||||
import {clusterPublish, setUidProcessId} from './clusterUtils';
|
import {clusterPublish, setUidProcessId} from './clusterUtils';
|
||||||
import {clearGud, getGud} from './public/gud';
|
import {clearGud, getGud} from './public/gud';
|
||||||
import { mylogger } from './gameLog';
|
import {mylogger} from './gameLog';
|
||||||
|
|
||||||
export async function createWs() {
|
export async function createWs() {
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ export async function createWs() {
|
|||||||
//API超时时间5分钟,为登陆排队做准备
|
//API超时时间5分钟,为登陆排队做准备
|
||||||
apiTimeout: 300000,
|
apiTimeout: 300000,
|
||||||
logLevel: G.argv.logModel as LogLevel,
|
logLevel: G.argv.logModel as LogLevel,
|
||||||
logger:mylogger
|
logger: mylogger
|
||||||
});
|
});
|
||||||
setCrossWs(G.serverCross);
|
setCrossWs(G.serverCross);
|
||||||
await G.serverCross.autoImplementApi(resolve(__dirname, 'api_cross'), true);
|
await G.serverCross.autoImplementApi(resolve(__dirname, 'api_cross'), true);
|
||||||
@ -39,7 +39,7 @@ export async function createWs() {
|
|||||||
wss: getWssFile(),
|
wss: getWssFile(),
|
||||||
//API超时时间5分钟,为登陆排队做准备,只针对游服
|
//API超时时间5分钟,为登陆排队做准备,只针对游服
|
||||||
apiTimeout: 300000,
|
apiTimeout: 300000,
|
||||||
logger:mylogger
|
logger: mylogger
|
||||||
});
|
});
|
||||||
setWs(G.server);
|
setWs(G.server);
|
||||||
await G.server.autoImplementApi(resolve(__dirname, 'api_s2c'), true);
|
await G.server.autoImplementApi(resolve(__dirname, 'api_s2c'), true);
|
||||||
@ -140,7 +140,7 @@ function setWs(server: WsServer<ServiceType>) {
|
|||||||
//处理API锁,极限情况下只锁10s,防止死锁
|
//处理API锁,极限情况下只锁10s,防止死锁
|
||||||
//在下方postApiReturnFlow里会解锁
|
//在下方postApiReturnFlow里会解锁
|
||||||
if (call.conn.apiLock[call.service.name] && call.conn.apiLock[call.service.name] > new Date().getTime()) {
|
if (call.conn.apiLock[call.service.name] && call.conn.apiLock[call.service.name] > new Date().getTime()) {
|
||||||
call.error('', {code: -100, message: '', time: 0});
|
call.error('', {code: -100, message: '', apilock: 1});
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,10 +198,14 @@ function setWs(server: WsServer<ServiceType>) {
|
|||||||
//API解锁
|
//API解锁
|
||||||
let now = new Date().getTime();
|
let now = new Date().getTime();
|
||||||
|
|
||||||
if(node.return.isSucc){
|
if (node.return.isSucc) {
|
||||||
node.call.conn.apiLock[node.call.service.name] = now+200;
|
if (!writeList.includes(node.call.service.name)){
|
||||||
}else{
|
node.call.conn.apiLock[node.call.service.name] = now + 200;
|
||||||
delete node.call.conn.apiLock[node.call.service.name];
|
}
|
||||||
|
} else {
|
||||||
|
if (!node.return.err.apilock) {
|
||||||
|
delete node.call.conn.apiLock[node.call.service.name];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
|
Loading…
Reference in New Issue
Block a user