feat 自定义拦截器
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"git.hlsq.asia/mmorpg/service-common/log"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/ss/ss_pb"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/global"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/handler/ws_handler/client"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"sync"
|
||||
@@ -39,8 +40,10 @@ func (s *Server) ToClient(server grpc_pb.Gateway_ToClientServer) error {
|
||||
log.Errorf("ToClient proto.Marshal error: %v", err)
|
||||
continue
|
||||
}
|
||||
dataLen := float64(len(data))
|
||||
for _, cli := range client.UserMgr.GetAll() {
|
||||
cli.WriteBytesPreMarshal(data)
|
||||
global.FlowCounter.Add(dataLen)
|
||||
}
|
||||
|
||||
//for _, client := range ws_handler.UserMgr.GetAll() {
|
||||
@@ -49,6 +52,7 @@ func (s *Server) ToClient(server grpc_pb.Gateway_ToClientServer) error {
|
||||
} else {
|
||||
if cli := client.UserMgr.GetByUSN(args.USN); cli != nil {
|
||||
cli.WriteBytes(ss_pb.MessageID(args.MessageID), args.Payload)
|
||||
global.FlowCounter.Add(float64(len(args.Payload)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user