diff --git a/.gitignore b/.gitignore index 45b3993..d8c7cab 100644 --- a/.gitignore +++ b/.gitignore @@ -106,4 +106,4 @@ dist # CrepeSR config.json -src/data/proto \ No newline at end of file +src/data/* \ No newline at end of file diff --git a/src/commands/debug.ts b/src/commands/debug.ts index fec4b68..55c1919 100644 --- a/src/commands/debug.ts +++ b/src/commands/debug.ts @@ -14,6 +14,7 @@ export default async function handle(command: Command) { } Config.VERBOSE_LEVEL = level as unknown as VerboseLevel; + Logger.VERBOSE_LEVEL = level as unknown as VerboseLevel; c.log(`VerboseLevel set to ${Config.VERBOSE_LEVEL} (${VerboseLevel[level]})`); } } \ No newline at end of file diff --git a/src/db/Account.ts b/src/db/Account.ts index 41451da..9d909cc 100644 --- a/src/db/Account.ts +++ b/src/db/Account.ts @@ -64,6 +64,11 @@ export default class Account { } await db.delete("accounts", { _id: Number(uid) }); } + + public async save() { + const db = Database.getInstance(); + await db.update("accounts", { _id: Number(this.uid) }, this); + } } function generateToken(): string { diff --git a/src/db/Database.ts b/src/db/Database.ts index 09e388b..00cd847 100644 --- a/src/db/Database.ts +++ b/src/db/Database.ts @@ -65,4 +65,18 @@ export default class Database { c.error(e as Error); } } + + public async update(collection: string, query: {}, payload: {}) { + try { + const db = await Database.client.db(); + const _collection = db.collection(collection); + if (!(await db.listCollections({ name: collection }).toArray()).length) { + c.warn(`Collection ${collection} does not exist. Creating...`); + await _collection.createIndexes([{ key: { id: 1 }, unique: true }]); + } + return await _collection.updateOne(query, { $set: payload }, { upsert: true }); + } catch (e) { + c.error(e as Error); + } + } } \ No newline at end of file diff --git a/src/db/Player.ts b/src/db/Player.ts index b9b6871..da31543 100644 --- a/src/db/Player.ts +++ b/src/db/Player.ts @@ -63,6 +63,6 @@ export default class Player { public async save() { const db = Database.getInstance(); - await db.set("players", this.db); + await db.update("players", { _id: this.db._id } , this.db); } } \ No newline at end of file diff --git a/src/server/packets/GetAllLineupDataCsReq.ts b/src/server/packets/GetAllLineupDataCsReq.ts new file mode 100644 index 0000000..22fc5f5 --- /dev/null +++ b/src/server/packets/GetAllLineupDataCsReq.ts @@ -0,0 +1,12 @@ +import { GetAllLineupDataCsReq, GetAllLineupDataScRsp } from "../../data/proto/StarRail"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as GetAllLineupDataCsReq; + + session.send("GetAllLineupDataScRsp", { + retcode: 0, + lineupList: [] + } as unknown as GetAllLineupDataScRsp); +} \ No newline at end of file diff --git a/src/server/packets/GetAvatarDataCsReq.ts b/src/server/packets/GetAvatarDataCsReq.ts new file mode 100644 index 0000000..d856e4f --- /dev/null +++ b/src/server/packets/GetAvatarDataCsReq.ts @@ -0,0 +1,31 @@ +import { ActivateFarmElementCsReq, GetAvatarDataCsReq, GetAvatarDataScRsp } from "../../data/proto/StarRail"; +import AvatarExcelTable from "../../data/excel/AvatarExcelTable.json"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as GetAvatarDataCsReq; + + const dataObj = { + retcode: 0, + avatarList: [{ + + }], + isAll: false + } as GetAvatarDataScRsp; + + Object.values(AvatarExcelTable).forEach(avatar => { + dataObj.avatarList.push({ + baseAvatarId: avatar.AvatarID, + equipmentUniqueId: 13501, + equipRelicList: [], + exp: 0, + level: 1, + promotion: 1, + rank: 100101, + skilltreeList: avatar.SkillList.map(skill => ({level: 1, pointId: skill})), + }) + }); + + session.send("GetAvatarDataScRsp", dataObj); +} \ No newline at end of file diff --git a/src/server/packets/GetBagCsReq.ts b/src/server/packets/GetBagCsReq.ts new file mode 100644 index 0000000..9c1ad85 --- /dev/null +++ b/src/server/packets/GetBagCsReq.ts @@ -0,0 +1,16 @@ +import { GetBagCsReq, GetBagScRsp } from "../../data/proto/StarRail"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as GetBagCsReq; + + session.send("GetBagScRsp", { + equipmentList: [], + materialList: [], + relicList: [], + retcode: 0, + rogueItemList: [], + waitDelResourceList: [] + } as GetBagScRsp); +} \ No newline at end of file diff --git a/src/server/packets/GetBasicInfoCsReq.ts b/src/server/packets/GetBasicInfoCsReq.ts new file mode 100644 index 0000000..a83f0bb --- /dev/null +++ b/src/server/packets/GetBasicInfoCsReq.ts @@ -0,0 +1,15 @@ +import { GetBasicInfoCsReq, GetBasicInfoScRsp } from "../../data/proto/StarRail"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as GetBasicInfoCsReq; + + session.send("GetBasicInfoScRsp", { + curDay: 1, + exchangeTimes: 0, + retcode: 0, + nextRecoverTime: Math.round(new Date().getTime() / 1000) + 100000, + weekCocoonFinishedCount: 0 + } as GetBasicInfoScRsp) +} \ No newline at end of file diff --git a/src/server/packets/GetChallengeCsReq.ts b/src/server/packets/GetChallengeCsReq.ts new file mode 100644 index 0000000..325d044 --- /dev/null +++ b/src/server/packets/GetChallengeCsReq.ts @@ -0,0 +1,12 @@ +import { GetChallengeCsReq, GetChallengeScRsp } from "../../data/proto/StarRail"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as GetChallengeCsReq; + + session.send("GetChallengeScRsp", { + retcode: 0, + challengeList: [] + } as GetChallengeScRsp); +} \ No newline at end of file diff --git a/src/server/packets/GetChallengeRaidInfoCsReq.ts b/src/server/packets/GetChallengeRaidInfoCsReq.ts new file mode 100644 index 0000000..d3bad49 --- /dev/null +++ b/src/server/packets/GetChallengeRaidInfoCsReq.ts @@ -0,0 +1,13 @@ +import { GetChallengeRaidInfoCsReq, GetChallengeRaidInfoScRsp } from "../../data/proto/StarRail"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as GetChallengeRaidInfoCsReq; + + session.send("GetChallengeRaidInfoScRsp", { + retcode: 0, + challengeRaidList: [], + takenRewardIdList: [] + } as GetChallengeRaidInfoScRsp); +} \ No newline at end of file diff --git a/src/server/packets/GetCurBattleInfoCsReq.ts b/src/server/packets/GetCurBattleInfoCsReq.ts new file mode 100644 index 0000000..b550b40 --- /dev/null +++ b/src/server/packets/GetCurBattleInfoCsReq.ts @@ -0,0 +1,26 @@ +import { AvatarType, GetCurBattleInfoCsReq, GetCurBattleInfoScRsp } from "../../data/proto/StarRail"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as GetCurBattleInfoCsReq; + + session.send("GetCurBattleInfoScRsp", { + retcode: 0, + avatarList: [{ + avatarType: AvatarType.AVATAR_TRIAL_TYPE, + hp: 1000, + id: 1001, + index: 1, + sp: 100, + level: 1, + promotion: 1, + rank: 100101, + equipmentList: [], + relicList: [], + skilltreeList: [100101] + }], + stageId: 10000, + logicRandomSeed: 2503 + } as unknown as GetCurBattleInfoScRsp); +} \ No newline at end of file diff --git a/src/server/packets/GetCurLineupDataCsReq.ts b/src/server/packets/GetCurLineupDataCsReq.ts new file mode 100644 index 0000000..e71e08a --- /dev/null +++ b/src/server/packets/GetCurLineupDataCsReq.ts @@ -0,0 +1,20 @@ +import { GetCurLineupDataCsReq, GetCurLineupDataScRsp } from "../../data/proto/StarRail"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as GetCurLineupDataCsReq; + + session.send("GetCurLineupDataScRsp", { + retcode: 0, + lineup: { + avatarList: [1001, 1002], + index: 1, + isVirtual: false, + mp: 100, + name: "lineuprspname", + planeId: 10000, + leaderSlot: 1, + } + } as unknown as GetCurLineupDataScRsp); +} \ No newline at end of file diff --git a/src/server/packets/GetCurSceneInfoCsReq.ts b/src/server/packets/GetCurSceneInfoCsReq.ts new file mode 100644 index 0000000..4891d8a --- /dev/null +++ b/src/server/packets/GetCurSceneInfoCsReq.ts @@ -0,0 +1,21 @@ +import { GetCurSceneInfoCsReq, GetCurSceneInfoScRsp } from "../../data/proto/StarRail"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as GetCurSceneInfoCsReq; + + session.send("GetCurSceneInfoScRsp", { + retcode: 0, + scene: { + planeId: 10000, + floorId: 10000000, + entityList: [], + entityBuffList: [], + entryId: 10001, + envBuffList: [], + gameModeType: 1, + lightenSectionList: [] + }, + } as unknown as GetCurSceneInfoScRsp); +} \ No newline at end of file diff --git a/src/server/packets/GetDialogueEventDataCsReq.ts b/src/server/packets/GetDialogueEventDataCsReq.ts new file mode 100644 index 0000000..15eb14f --- /dev/null +++ b/src/server/packets/GetDialogueEventDataCsReq.ts @@ -0,0 +1,12 @@ +import { GetDialogueEventDataCsReq, GetDialogueEventDataScRsp } from "../../data/proto/StarRail"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as GetDialogueEventDataCsReq; + + session.send("GetDialogueEventDataScRsp", { + dialogueEventList: [], + retcode: 0 + } as GetDialogueEventDataScRsp); +} \ No newline at end of file diff --git a/src/server/packets/GetExpeditionDataCsReq.ts b/src/server/packets/GetExpeditionDataCsReq.ts new file mode 100644 index 0000000..2a2e532 --- /dev/null +++ b/src/server/packets/GetExpeditionDataCsReq.ts @@ -0,0 +1,14 @@ +import { GetExpeditionDataCsReq, GetExpeditionDataScRsp } from "../../data/proto/StarRail"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as GetExpeditionDataCsReq; + + session.send("GetExpeditionDataScRsp", { + retcode: 0, + expedtionList: [], + unlockedExpeditionIdList: [], + teamCount: 4 + } as GetExpeditionDataScRsp); +} \ No newline at end of file diff --git a/src/server/packets/GetFirstTalkNpcCsReq.ts b/src/server/packets/GetFirstTalkNpcCsReq.ts new file mode 100644 index 0000000..73dd33f --- /dev/null +++ b/src/server/packets/GetFirstTalkNpcCsReq.ts @@ -0,0 +1,11 @@ +import { GetFirstTalkNpcCsReq, GetFirstTalkNpcScRsp } from "../../data/proto/StarRail"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as GetFirstTalkNpcCsReq; + + session.send("GetFirstTalkNpcScRsp", { + retcode: 0, + } as GetFirstTalkNpcScRsp); +} \ No newline at end of file diff --git a/src/server/packets/GetHeroBasicTypeInfoCsReq.ts b/src/server/packets/GetHeroBasicTypeInfoCsReq.ts new file mode 100644 index 0000000..5a0f84a --- /dev/null +++ b/src/server/packets/GetHeroBasicTypeInfoCsReq.ts @@ -0,0 +1,28 @@ +import { Gender, GetHeroBasicTypeInfoCsReq, GetHeroBasicTypeInfoScRsp, HeroBasicType } from "../../data/proto/StarRail"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as GetHeroBasicTypeInfoCsReq; + + session.send("GetHeroBasicTypeInfoScRsp", { + retcode: 0, + gender: Gender.GenderMan, + basicTypeInfoList: [{ + basicType: HeroBasicType.BoyMage, + rank: 1, + skillTreeList: [{ + level: 1, + pointId: 1 + }] + }], + curBasicType: HeroBasicType.BoyMage, + heroPathList: [{ + exp: 0, + level: 1, + heroPathType: 1 + }], + isPlayerInfoModified: false, + isGenderModified: false + } as GetHeroBasicTypeInfoScRsp); +} \ No newline at end of file diff --git a/src/server/packets/GetHeroPathCsReq.ts b/src/server/packets/GetHeroPathCsReq.ts new file mode 100644 index 0000000..e112adc --- /dev/null +++ b/src/server/packets/GetHeroPathCsReq.ts @@ -0,0 +1,16 @@ +import { GetHeroPathCsReq, GetHeroPathScRsp } from "../../data/proto/StarRail"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as GetHeroPathCsReq; + + session.send("GetHeroPathScRsp", { + retcode: 0, + heroPathList: [{ + exp: 0, + level: 1, + heroPathType: 1 + }] + } as GetHeroPathScRsp); +} \ No newline at end of file diff --git a/src/server/packets/GetLevelRewardTakenListCsReq.ts b/src/server/packets/GetLevelRewardTakenListCsReq.ts new file mode 100644 index 0000000..aefb117 --- /dev/null +++ b/src/server/packets/GetLevelRewardTakenListCsReq.ts @@ -0,0 +1,12 @@ +import { GetLevelRewardTakenListCsReq, GetLevelRewardTakenListScRsp } from "../../data/proto/StarRail"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as GetLevelRewardTakenListCsReq; + + session.send("GetLevelRewardTakenListScRsp", { + retcode: 0, + takenLevelList: [] + } as GetLevelRewardTakenListScRsp); +} \ No newline at end of file diff --git a/src/server/packets/GetLoginActivityCsReq.ts b/src/server/packets/GetLoginActivityCsReq.ts new file mode 100644 index 0000000..8443825 --- /dev/null +++ b/src/server/packets/GetLoginActivityCsReq.ts @@ -0,0 +1,16 @@ +import { GetLoginActivityCsReq, GetLoginActivityScRsp } from "../../data/proto/StarRail"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as GetLoginActivityCsReq; + + session.send("GetLoginActivityScRsp", { + retcode: 0, + loginActivityList: [{ + hasTakenLoginActivityRewardDaysList: [], + id: 1000, + loginDays: 1, + }] + } as GetLoginActivityScRsp); +} \ No newline at end of file diff --git a/src/server/packets/GetMailCsReq.ts b/src/server/packets/GetMailCsReq.ts new file mode 100644 index 0000000..40b9cb3 --- /dev/null +++ b/src/server/packets/GetMailCsReq.ts @@ -0,0 +1,16 @@ +import { GetMailCsReq, GetMailScRsp } from "../../data/proto/StarRail"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as GetMailCsReq; + + session.send("GetMailScRsp", { + retcode: 0, + mailList: [], + noticeMailList: [], + start: 0, + totalNum: 0, + isEnd: false + } as GetMailScRsp); +} \ No newline at end of file diff --git a/src/server/packets/GetMazeTimeOfDayCsReq.ts b/src/server/packets/GetMazeTimeOfDayCsReq.ts new file mode 100644 index 0000000..30bf2db --- /dev/null +++ b/src/server/packets/GetMazeTimeOfDayCsReq.ts @@ -0,0 +1,12 @@ +import { GetMazeTimeOfDayCsReq, GetMazeTimeOfDayScRsp } from "../../data/proto/StarRail"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as GetMazeTimeOfDayCsReq; + + session.send("GetMazeTimeOfDayScRsp", { + retcode: 0, + mazeTimeOfDayMap: {} + } as GetMazeTimeOfDayScRsp); +} \ No newline at end of file diff --git a/src/server/packets/GetMissionDataCsReq.ts b/src/server/packets/GetMissionDataCsReq.ts new file mode 100644 index 0000000..01507f8 --- /dev/null +++ b/src/server/packets/GetMissionDataCsReq.ts @@ -0,0 +1,12 @@ +import { GetMissionDataCsReq, GetMissionDataScRsp } from "../../data/proto/StarRail"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as GetMissionDataCsReq; + + session.send("GetMissionDataScRsp", { + retcode: 0, + missionList: [] + } as unknown as GetMissionDataScRsp); +} \ No newline at end of file diff --git a/src/server/packets/GetMissionEventDataCsReq.ts b/src/server/packets/GetMissionEventDataCsReq.ts new file mode 100644 index 0000000..261e344 --- /dev/null +++ b/src/server/packets/GetMissionEventDataCsReq.ts @@ -0,0 +1,12 @@ +import { GetMissionEventDataCsReq, GetMissionEventDataScRsp } from "../../data/proto/StarRail"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as GetMissionEventDataCsReq; + + session.send("GetMissionEventDataScRsp", { + retcode: 0, + missionEventList: [] + } as unknown as GetMissionEventDataScRsp); +} \ No newline at end of file diff --git a/src/server/packets/GetMissionStatusCsReq.ts b/src/server/packets/GetMissionStatusCsReq.ts new file mode 100644 index 0000000..ce8bc56 --- /dev/null +++ b/src/server/packets/GetMissionStatusCsReq.ts @@ -0,0 +1,15 @@ +import { GetMissionStatusCsReq, GetMissionStatusScRsp } from "../../data/proto/StarRail"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as GetMissionStatusCsReq; + + session.send("GetMissionStatusScRsp", { + retcode: 0, + finishedMainMissionIdList: [], + missionEventStatusList: [], + subMissionStatusList: [], + unfinishedMainMissionIdList: [] + } as GetMissionStatusScRsp); +} \ No newline at end of file diff --git a/src/server/packets/GetNpcStatusCsReq.ts b/src/server/packets/GetNpcStatusCsReq.ts new file mode 100644 index 0000000..d941df2 --- /dev/null +++ b/src/server/packets/GetNpcStatusCsReq.ts @@ -0,0 +1,12 @@ +import { GetNpcStatusCsReq, GetNpcStatusScRsp } from "../../data/proto/StarRail"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as GetNpcStatusCsReq; + + session.send("GetNpcStatusScRsp", { + retcode: 0, + messageStatusList: [] + } as GetNpcStatusScRsp); +} \ No newline at end of file diff --git a/src/server/packets/GetQuestDataCsReq.ts b/src/server/packets/GetQuestDataCsReq.ts new file mode 100644 index 0000000..102deab --- /dev/null +++ b/src/server/packets/GetQuestDataCsReq.ts @@ -0,0 +1,14 @@ +import { GetQuestDataCsReq, GetQuestDataScRsp } from "../../data/proto/StarRail"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as GetQuestDataCsReq; + + session.send("GetQuestDataScRsp", { + questList: [], + retcode: 0, + takenAchievementLevelList: [], + totalAchievementExp: 1, + } as GetQuestDataScRsp); +} \ No newline at end of file diff --git a/src/server/packets/GetRogueInfoCsReq.ts b/src/server/packets/GetRogueInfoCsReq.ts new file mode 100644 index 0000000..1224f0a --- /dev/null +++ b/src/server/packets/GetRogueInfoCsReq.ts @@ -0,0 +1,12 @@ +import { GetRogueInfoCsReq, GetRogueInfoScRsp } from "../../data/proto/StarRail"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as GetRogueInfoCsReq; + + session.send("GetRogueInfoScRsp", { + retcode: 0, + + } as GetRogueInfoScRsp); +} \ No newline at end of file diff --git a/src/server/packets/GetSpringRecoverDataCsReq.ts b/src/server/packets/GetSpringRecoverDataCsReq.ts new file mode 100644 index 0000000..ede3959 --- /dev/null +++ b/src/server/packets/GetSpringRecoverDataCsReq.ts @@ -0,0 +1,20 @@ +import { GetSpringRecoverDataCsReq, GetSpringRecoverDataScRsp } from "../../data/proto/StarRail"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as GetSpringRecoverDataCsReq; + + session.send("GetSpringRecoverDataScRsp", { + retcode: 0, + healPoolInfo: { + healPool: 0, + refreshTime: 600, + }, + springRecoverConfig: { + autoRecoverHp: true, + defaultHp: 100, + avatarPresetHpList: [] + } + } as GetSpringRecoverDataScRsp); +} \ No newline at end of file diff --git a/src/server/packets/PlayerKeepAliveNotify.ts b/src/server/packets/PlayerKeepAliveNotify.ts new file mode 100644 index 0000000..046ac41 --- /dev/null +++ b/src/server/packets/PlayerKeepAliveNotify.ts @@ -0,0 +1,9 @@ +import { PlayerKeepAliveNotify } from "../../data/proto/StarRail"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as PlayerKeepAliveNotify; + + // We actually don't need to handle this +} \ No newline at end of file diff --git a/src/server/packets/SyncTimeCsReq.ts b/src/server/packets/SyncTimeCsReq.ts new file mode 100644 index 0000000..87055ab --- /dev/null +++ b/src/server/packets/SyncTimeCsReq.ts @@ -0,0 +1,13 @@ +import { SyncTimeCsReq, SyncTimeScRsp } from "../../data/proto/StarRail"; +import Packet from "../kcp/Packet"; +import Session from "../kcp/Session"; + +export default async function handle(session: Session, packet: Packet) { + const body = packet.body as SyncTimeCsReq; + + session.send("SyncTimeScRsp", { + retcode: 0, + clientTimeMs: body.clientTimeMs, + serverTimeMs: Math.round(new Date().getTime() / 1000).toString() + } as unknown as SyncTimeScRsp); +} \ No newline at end of file