feat 修改usn类型为string

This commit is contained in:
2026-01-11 16:16:16 +08:00
parent 5af027b35c
commit 9e1889b956
13 changed files with 34 additions and 36 deletions

View File

@@ -9,7 +9,6 @@ import (
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
"strconv"
"strings"
"time"
)
@@ -73,7 +72,7 @@ func authJwt() gin.HandlerFunc {
}
// 这里将Header写到请求中grpc-gateway框架会读取然后传给grpc服务
c.Request.Header.Set("X-Usn", strconv.Itoa(int(claims.USN)))
c.Request.Header.Set("X-Usn", claims.USN)
c.Next()
}
}

View File

@@ -44,7 +44,7 @@ func (g *GatewayWsServer) OnHandShake(conn socket.ISocketConn) socket.Action {
func (g *GatewayWsServer) OnMessage(conn socket.ISocketConn, bytes []byte) socket.Action {
cli, ok := conn.GetParam("client").(*client.Client)
if !ok || cli.USN == 0 || cli.Status != 1 {
if !ok || cli.USN == "" || cli.Status != 1 {
return socket.Close
}
cli.OnEvent(&client.ClientEvent{Msg: bytes})
@@ -53,7 +53,7 @@ func (g *GatewayWsServer) OnMessage(conn socket.ISocketConn, bytes []byte) socke
func (g *GatewayWsServer) OnPong(conn socket.ISocketConn) {
cli, ok := conn.GetParam("client").(*client.Client)
if !ok || cli.USN == 0 {
if !ok || cli.USN == "" {
return
}
cli.OnEvent(&client.PongEvent{})