Files
core_ng/server/ProcDecorator/ReqGameLogin.ts
T
2023-08-18 14:13:46 +00:00

35 lines
1.1 KiB
TypeScript

import type { LoginCtx } from "./ReqLogin.js";
import type { SessionCtx } from "./StartSession.js";
import type { ProcDecoratorGenerator } from "./base.js";
export type GameLoginCtx = {
generalID: number;
generalName: string;
gameLoginDate: Date;
}
export function ReqGameLogin<Q extends LoginCtx & SessionCtx>(): ProcDecoratorGenerator<GameLoginCtx, Q> {
return async (ctx) => {
//NOTE: 게임 서버별로 gameLoginCtx를 따로 가져야 하는가?
let gameLoginCtx = ctx.session.getItem<GameLoginCtx>(`gameLoginCtx`);
if(gameLoginCtx){
if(gameLoginCtx.gameLoginDate >= ctx.loginDate){
return [{
result: true,
},{
...gameLoginCtx,
...ctx,
}];
}
gameLoginCtx = undefined;
}
//TODO: DB에서 generalID를 가져오는 로직
return [{
result: false,
type: 'Required GameLogin',
info: 'NotYetImplemented'
}, ctx];
}
}