From 7d2c2ab02536f66a441ddf41f435f08bf7aa1587 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 14:16:33 +0800 Subject: [PATCH] fix --- server/websocket/internal/handler/datatransferhandler.go | 2 +- server/websocket/internal/logic/datatransferlogic.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/websocket/internal/handler/datatransferhandler.go b/server/websocket/internal/handler/datatransferhandler.go index 8ef09842..c167b31c 100644 --- a/server/websocket/internal/handler/datatransferhandler.go +++ b/server/websocket/internal/handler/datatransferhandler.go @@ -10,6 +10,6 @@ func DataTransferHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { // 创建一个业务逻辑层实例 l := logic.NewDataTransferLogic(r.Context(), svcCtx) - l.DataTransfer(svcCtx, w, r) + l.DataTransfer(w, r) } } diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 2bf05623..7288256b 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -79,7 +79,7 @@ type wsConnectItem struct { renderProperty renderProperty //扩展云渲染属性 } -func (l *DataTransferLogic) DataTransfer(svcCtx *svc.ServiceContext, w http.ResponseWriter, r *http.Request) { +func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) { //升级websocket conn, err := upgrade.Upgrade(w, r, nil) if err != nil { @@ -92,7 +92,7 @@ func (l *DataTransferLogic) DataTransfer(svcCtx *svc.ServiceContext, w http.Resp userInfo *auth.UserInfo isAuth bool ) - isAuth, userInfo = l.checkAuth(svcCtx, r) + isAuth, userInfo = l.checkAuth(r) if !isAuth { time.Sleep(time.Second * 1) //兼容下火狐 rsp := websocket_data.DataTransferData{ @@ -170,9 +170,9 @@ func getUserPart(userId, guestId int64) string { } // 鉴权 -func (l *DataTransferLogic) checkAuth(svcCtx *svc.ServiceContext, r *http.Request) (isAuth bool, userInfo *auth.UserInfo) { +func (l *DataTransferLogic) checkAuth(r *http.Request) (isAuth bool, userInfo *auth.UserInfo) { // 解析JWT token,并对空用户进行判断 - claims, err := svcCtx.ParseJwtToken(r) + claims, err := l.svcCtx.ParseJwtToken(r) // 如果解析JWT token出错,则返回未授权的JSON响应并记录错误消息 if err != nil { return false, nil