This commit is contained in:
laodaming 2023-11-02 12:15:52 +08:00
parent cd75ee795f
commit afbf183b97
3 changed files with 12 additions and 16 deletions

View File

@ -11,7 +11,6 @@ import (
"fusenapi/utils/basic" "fusenapi/utils/basic"
"fusenapi/utils/file" "fusenapi/utils/file"
"fusenapi/utils/websocket_data" "fusenapi/utils/websocket_data"
"strings"
"time" "time"
"github.com/zeromicro/go-zero/core/logx" "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) { // func (l *RenderNotifyLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
// // httpx.OkJsonCtx(r.Context(), w, resp) // // httpx.OkJsonCtx(r.Context(), w, resp)
// } // }
func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *auth.UserInfo) (resp *basic.Response) { 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() unityRenderEndTime := time.Now().UTC().UnixMilli()
//解析数据 //解析数据
var info websocket_data.ToUnityIdStruct var info websocket_data.ToUnityIdStruct
@ -59,6 +46,14 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a
logx.Error("解析taskId错误") logx.Error("解析taskId错误")
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "failed to parse param 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 wid := info.Wid
requestId := info.RequestId requestId := info.RequestId

View File

@ -34,6 +34,8 @@ type mapUserWsStatItem struct {
// 统计信息 // 统计信息
var ( var (
// 服务启动时间
serverStartTime = time.Now().UTC().UnixMilli()
//用户连接统计 //用户连接统计
mapUserWsStat = sync.Map{} mapUserWsStat = sync.Map{}
//消息控制通道的数据结构 //消息控制通道的数据结构

View File

@ -5,11 +5,10 @@ import (
"flag" "flag"
"fmt" "fmt"
"fusenapi/server/websocket/internal/logic" "fusenapi/server/websocket/internal/logic"
"github.com/zeromicro/go-zero/core/logx"
"net/http"
"fusenapi/utils/auth" "fusenapi/utils/auth"
"fusenapi/utils/fsconfig" "fusenapi/utils/fsconfig"
"github.com/zeromicro/go-zero/core/logx"
"net/http"
"fusenapi/server/websocket/internal/config" "fusenapi/server/websocket/internal/config"
"fusenapi/server/websocket/internal/handler" "fusenapi/server/websocket/internal/handler"