diff --git a/server/websocket/internal/logic/rendernotifylogic.go b/server/websocket/internal/logic/rendernotifylogic.go index 1d08b889..0db5c748 100644 --- a/server/websocket/internal/logic/rendernotifylogic.go +++ b/server/websocket/internal/logic/rendernotifylogic.go @@ -11,7 +11,6 @@ import ( "fusenapi/utils/basic" "fusenapi/utils/file" "fusenapi/utils/websocket_data" - "strings" "time" "github.com/zeromicro/go-zero/core/logx" @@ -39,19 +38,7 @@ func NewRenderNotifyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Rend // func (l *RenderNotifyLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) { // // httpx.OkJsonCtx(r.Context(), w, resp) // } - func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *auth.UserInfo) (resp *basic.Response) { - //统计unity处理数 - decreaseUnityRequestCount(req.UserId, req.GuestId) - if req.Code != 0 { - //统计unity失败处理数 - increaseUnityErrorCount(req.UserId, req.GuestId) - } - req.TaskId = strings.Trim(req.TaskId, " ") - if req.TaskId == "" { - logx.Error("渲染回调参数错误:任务标识") - return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param task_id") - } unityRenderEndTime := time.Now().UTC().UnixMilli() //解析数据 var info websocket_data.ToUnityIdStruct @@ -59,6 +46,14 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a logx.Error("解析taskId错误") return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "failed to parse param taskId !!!!") } + if info.RenderBeginTime > serverStartTime { + //统计unity处理数 + decreaseUnityRequestCount(req.UserId, req.GuestId) + if req.Code != 0 { + //统计unity失败处理数 + increaseUnityErrorCount(req.UserId, req.GuestId) + } + } //重新赋值(很重要) wid := info.Wid requestId := info.RequestId diff --git a/server/websocket/internal/logic/ws_statistics.go b/server/websocket/internal/logic/ws_statistics.go index 73b0aa4f..72ce3bb8 100644 --- a/server/websocket/internal/logic/ws_statistics.go +++ b/server/websocket/internal/logic/ws_statistics.go @@ -34,6 +34,8 @@ type mapUserWsStatItem struct { // 统计信息 var ( + // 服务启动时间 + serverStartTime = time.Now().UTC().UnixMilli() //用户连接统计 mapUserWsStat = sync.Map{} //消息控制通道的数据结构 diff --git a/server/websocket/websocket.go b/server/websocket/websocket.go index 562e9e43..969c2c33 100644 --- a/server/websocket/websocket.go +++ b/server/websocket/websocket.go @@ -5,11 +5,10 @@ import ( "flag" "fmt" "fusenapi/server/websocket/internal/logic" - "github.com/zeromicro/go-zero/core/logx" - "net/http" - "fusenapi/utils/auth" "fusenapi/utils/fsconfig" + "github.com/zeromicro/go-zero/core/logx" + "net/http" "fusenapi/server/websocket/internal/config" "fusenapi/server/websocket/internal/handler"