feat 排队

This commit is contained in:
2026-01-06 18:36:15 +08:00
parent 8289e2b4d9
commit 46839cd11b
20 changed files with 482 additions and 96 deletions

View File

@@ -4,7 +4,8 @@ import (
"common/log"
"common/proto/sc/sc_pb"
"common/proto/ss/grpc_pb"
"gateway/internal/handler/ws_handler"
"context"
"gateway/internal/handler/ws_handler/client"
"google.golang.org/protobuf/proto"
"sync"
)
@@ -38,16 +39,16 @@ func (s *Server) ToClient(server grpc_pb.Gateway_ToClientServer) error {
log.Errorf("ToClient proto.Marshal error: %v", err)
continue
}
for _, client := range ws_handler.UserMgr.GetAll() {
client.WriteBytesPreMarshal(data)
for _, cli := range client.UserMgr.GetAll() {
cli.WriteBytesPreMarshal(data)
}
//for _, client := range ws_handler.UserMgr.GetAll() {
// client.WriteBytes(sc_pb.MessageID(args.MessageID), args.Payload)
//}
} else {
if client := ws_handler.UserMgr.GetByUSN(args.USN); client != nil {
client.WriteBytes(sc_pb.MessageID(args.MessageID), args.Payload)
if cli := client.UserMgr.GetByUSN(args.USN); cli != nil {
cli.WriteBytes(sc_pb.MessageID(args.MessageID), args.Payload)
}
}
}
@@ -56,3 +57,7 @@ func (s *Server) ToClient(server grpc_pb.Gateway_ToClientServer) error {
wg.Wait()
return server.SendAndClose(&grpc_pb.ToClientResp{})
}
func (s *Server) KickUser(ctx context.Context, req *grpc_pb.KickUserReq) (*grpc_pb.KickUserResp, error) {
return &grpc_pb.KickUserResp{}, nil
}

View File

@@ -4,7 +4,7 @@ import (
"common/discover/common"
"common/net/grpc/service"
"common/proto/ss/grpc_pb"
"gateway/internal/handler/ws_handler"
"gateway/internal/handler/ws_handler/client"
"google.golang.org/grpc"
)
@@ -26,7 +26,7 @@ func NewServer(ttl int64) *Server {
}
func (s *Server) OnInit(serve *grpc.Server) {
ws_handler.GatewaySID = s.SID
client.GatewaySID = s.SID
grpc_pb.RegisterGatewayServer(serve, s)
}