diff --git a/src/api_s2c/user/ApiDot.ts b/src/api_s2c/user/ApiDot.ts new file mode 100644 index 0000000..bf42370 --- /dev/null +++ b/src/api_s2c/user/ApiDot.ts @@ -0,0 +1,10 @@ +import {ApiCall} from "tsrpc"; +import {ReqDot, ResDot} from "../../shared/protocols/user/PtlDot"; +import {addGameDot} from "../../gameLog"; + +export default async function (call: ApiCall) { + + addGameDot(call.uid, call.req.type, call.req.data) + + call.succ({}); +} \ No newline at end of file diff --git a/src/gameLog.ts b/src/gameLog.ts index 7f70f2c..65e62be 100644 --- a/src/gameLog.ts +++ b/src/gameLog.ts @@ -43,4 +43,30 @@ export async function addGameLog(uid:string, type:string, req:any, data:any){ }catch(e){ console.error('addGameLog',e); } +} + +/** + * 玩家游戏内打点 + * @param uid 玩家uid + * @param type 日志类型 + * @param data 日志内容 + */ + +export async function addGameDot(uid:string, type:string, data?:any){ + try{ + if(!logDB){ + await connGameLogDB(); + } + let log = { + uid, + type, + data + } + //事件时间 + log['cTime'] = Math.floor(Date.now()/1000); + + logDB.collection('gameDot').insertOne(log); + }catch(e){ + console.error('addGameLog',e); + } } \ No newline at end of file diff --git a/src/shared/protocols/user/PtlDot.ts b/src/shared/protocols/user/PtlDot.ts new file mode 100644 index 0000000..d81ccd0 --- /dev/null +++ b/src/shared/protocols/user/PtlDot.ts @@ -0,0 +1,8 @@ +export interface ReqDot { + type: string, + data?: any +} + +export interface ResDot { + +}