瀏覽代碼

v0.0.1开发:玩家断开客服连接开发

#Suyghur 2 年之前
父節點
當前提交
5f74f6e061

+ 1 - 1
bff/cmdbff/api/etc/cmdbff.yaml

@@ -10,7 +10,7 @@ Telemetry:
 
 CmdRpcConf:
   Endpoints:
-    - localhost:10300
+    - 127.0.0.1:10300
   NonBlock: true
 
 JwtAuth:

+ 1 - 1
core/cmd/rpc/etc/cmd.yaml

@@ -3,7 +3,7 @@ ListenOn: 0.0.0.0:10300
 
 InnerRpcConf:
   Endpoints:
-    - localhost:10500
+    - 127.0.0.1:10500
   NonBlock: true
 
 Telemetry:

+ 9 - 10
core/inner/rpc/internal/ext/global.go

@@ -50,6 +50,15 @@ func GetConnectedPlayerInfo(gameId, playerId string) *model.PlayerInfo {
 	return nil
 }
 
+func RemoveConnectedPlayerInfo(gameId, playerId string) {
+	if GameConnectedMap.Contains(gameId) {
+		connectedMap := GameConnectedMap.Get(gameId).(*treemap.Map)
+		if connectedMap.Contains(playerId) {
+			connectedMap.Erase(playerId)
+		}
+	}
+}
+
 func GetOnlinePlayerInfo(gameId, playerId string) *model.PlayerInfo {
 	if GameOnlinePlayerMap.Contains(gameId) {
 		onlinePlayerMap := GameOnlinePlayerMap.Get(gameId).(*treemap.Map)
@@ -59,13 +68,3 @@ func GetOnlinePlayerInfo(gameId, playerId string) *model.PlayerInfo {
 	}
 	return nil
 }
-
-func GetWaitingPlayerInfo(gameId, playerId string) *model.PlayerInfo {
-	for n := WaitingList.FrontNode(); n != nil; n = n.Next() {
-		playerInfo := n.Value.(*model.PlayerInfo)
-		if playerInfo.GameId == gameId && playerInfo.PlayerId == playerId {
-			return playerInfo
-		}
-	}
-	return nil
-}

+ 4 - 4
core/inner/rpc/internal/logic/playerdisconnectlogic.go

@@ -2,6 +2,7 @@ package logic
 
 import (
 	"context"
+	"ylink/core/inner/rpc/internal/ext"
 
 	"ylink/core/inner/rpc/internal/svc"
 	"ylink/core/inner/rpc/pb"
@@ -23,8 +24,7 @@ func NewPlayerDisconnectLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
 	}
 }
 
-func (l *PlayerDisconnectLogic) PlayerDisconnect(in *pb.InnerPlayerFetchCsInfoReq) (*pb.InnerPlayerFetchCsInfoResp, error) {
-	// todo: add your logic here and delete this line
-
-	return &pb.InnerPlayerFetchCsInfoResp{}, nil
+func (l *PlayerDisconnectLogic) PlayerDisconnect(in *pb.InnerPlayerDisconnectReq) (*pb.InnerPlayerDisconnectResp, error) {
+	ext.RemoveConnectedPlayerInfo(in.GameId, in.PlayerId)
+	return &pb.InnerPlayerDisconnectResp{}, nil
 }

+ 1 - 6
flowsrv/rpc/etc/flowsrv.yaml

@@ -7,14 +7,9 @@ Telemetry:
   Sampler: 1.0
   Batcher: jaeger
 
-AuthRpcConf:
-  Endpoints:
-    - localhost:10400
-  NonBlock: true
-
 InnerRpcConf:
   Endpoints:
-    - localhost:10500
+    - 127.0.0.1:10500
   NonBlock: true
 
 KqMsgBoxConsumerConf:

+ 0 - 6
flowsrv/rpc/flowsrv/flowsrv.go

@@ -18,7 +18,6 @@ type (
 
 	Flowsrv interface {
 		Connect(ctx context.Context, in *CommandReq, opts ...grpc.CallOption) (pb.Flowsrv_ConnectClient, error)
-		Disconnect(ctx context.Context, in *CommandReq, opts ...grpc.CallOption) (*CommandResp, error)
 	}
 
 	defaultFlowsrv struct {
@@ -36,8 +35,3 @@ func (m *defaultFlowsrv) Connect(ctx context.Context, in *CommandReq, opts ...gr
 	client := pb.NewFlowsrvClient(m.cli.Conn())
 	return client.Connect(ctx, in, opts...)
 }
-
-func (m *defaultFlowsrv) Disconnect(ctx context.Context, in *CommandReq, opts ...grpc.CallOption) (*CommandResp, error) {
-	client := pb.NewFlowsrvClient(m.cli.Conn())
-	return client.Disconnect(ctx, in, opts...)
-}

+ 0 - 7
flowsrv/rpc/internal/server/flowsrvserver.go

@@ -4,8 +4,6 @@
 package server
 
 import (
-	"context"
-
 	"ylink/flowsrv/rpc/internal/logic"
 	"ylink/flowsrv/rpc/internal/svc"
 	"ylink/flowsrv/rpc/pb"
@@ -26,8 +24,3 @@ func (s *FlowsrvServer) Connect(in *pb.CommandReq, stream pb.Flowsrv_ConnectServ
 	l := logic.NewConnectLogic(stream.Context(), s.svcCtx)
 	return l.Connect(in, stream)
 }
-
-func (s *FlowsrvServer) Disconnect(ctx context.Context, in *pb.CommandReq) (*pb.CommandResp, error) {
-	l := logic.NewDisconnectLogic(ctx, s.svcCtx)
-	return l.Disconnect(in)
-}

+ 6 - 11
flowsrv/rpc/pb/flowsrv.pb.go

@@ -154,14 +154,11 @@ var file_pb_flowsrv_proto_rawDesc = []byte{
 	0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03,
 	0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x12, 0x12,
 	0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61,
-	0x74, 0x61, 0x32, 0x66, 0x0a, 0x07, 0x46, 0x6c, 0x6f, 0x77, 0x73, 0x72, 0x76, 0x12, 0x2c, 0x0a,
+	0x74, 0x61, 0x32, 0x37, 0x0a, 0x07, 0x46, 0x6c, 0x6f, 0x77, 0x73, 0x72, 0x76, 0x12, 0x2c, 0x0a,
 	0x07, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x12, 0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f,
 	0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f,
-	0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x30, 0x01, 0x12, 0x2d, 0x0a, 0x0a, 0x64,
-	0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x12, 0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x43,
-	0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x70, 0x62, 0x2e, 0x43,
-	0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f,
-	0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x30, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e,
+	0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (
@@ -183,11 +180,9 @@ var file_pb_flowsrv_proto_goTypes = []interface{}{
 }
 var file_pb_flowsrv_proto_depIdxs = []int32{
 	0, // 0: pb.Flowsrv.connect:input_type -> pb.CommandReq
-	0, // 1: pb.Flowsrv.disconnect:input_type -> pb.CommandReq
-	1, // 2: pb.Flowsrv.connect:output_type -> pb.CommandResp
-	1, // 3: pb.Flowsrv.disconnect:output_type -> pb.CommandResp
-	2, // [2:4] is the sub-list for method output_type
-	0, // [0:2] is the sub-list for method input_type
+	1, // 1: pb.Flowsrv.connect:output_type -> pb.CommandResp
+	1, // [1:2] is the sub-list for method output_type
+	0, // [0:1] is the sub-list for method input_type
 	0, // [0:0] is the sub-list for extension type_name
 	0, // [0:0] is the sub-list for extension extendee
 	0, // [0:0] is the sub-list for field type_name

+ 1 - 38
flowsrv/rpc/pb/flowsrv_grpc.pb.go

@@ -23,7 +23,6 @@ const _ = grpc.SupportPackageIsVersion7
 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
 type FlowsrvClient interface {
 	Connect(ctx context.Context, in *CommandReq, opts ...grpc.CallOption) (Flowsrv_ConnectClient, error)
-	Disconnect(ctx context.Context, in *CommandReq, opts ...grpc.CallOption) (*CommandResp, error)
 }
 
 type flowsrvClient struct {
@@ -66,21 +65,11 @@ func (x *flowsrvConnectClient) Recv() (*CommandResp, error) {
 	return m, nil
 }
 
-func (c *flowsrvClient) Disconnect(ctx context.Context, in *CommandReq, opts ...grpc.CallOption) (*CommandResp, error) {
-	out := new(CommandResp)
-	err := c.cc.Invoke(ctx, "/pb.Flowsrv/disconnect", in, out, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return out, nil
-}
-
 // FlowsrvServer is the server API for Flowsrv service.
 // All implementations must embed UnimplementedFlowsrvServer
 // for forward compatibility
 type FlowsrvServer interface {
 	Connect(*CommandReq, Flowsrv_ConnectServer) error
-	Disconnect(context.Context, *CommandReq) (*CommandResp, error)
 	mustEmbedUnimplementedFlowsrvServer()
 }
 
@@ -91,9 +80,6 @@ type UnimplementedFlowsrvServer struct {
 func (UnimplementedFlowsrvServer) Connect(*CommandReq, Flowsrv_ConnectServer) error {
 	return status.Errorf(codes.Unimplemented, "method Connect not implemented")
 }
-func (UnimplementedFlowsrvServer) Disconnect(context.Context, *CommandReq) (*CommandResp, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method Disconnect not implemented")
-}
 func (UnimplementedFlowsrvServer) mustEmbedUnimplementedFlowsrvServer() {}
 
 // UnsafeFlowsrvServer may be embedded to opt out of forward compatibility for this service.
@@ -128,36 +114,13 @@ func (x *flowsrvConnectServer) Send(m *CommandResp) error {
 	return x.ServerStream.SendMsg(m)
 }
 
-func _Flowsrv_Disconnect_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(CommandReq)
-	if err := dec(in); err != nil {
-		return nil, err
-	}
-	if interceptor == nil {
-		return srv.(FlowsrvServer).Disconnect(ctx, in)
-	}
-	info := &grpc.UnaryServerInfo{
-		Server:     srv,
-		FullMethod: "/pb.Flowsrv/disconnect",
-	}
-	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(FlowsrvServer).Disconnect(ctx, req.(*CommandReq))
-	}
-	return interceptor(ctx, in, info, handler)
-}
-
 // Flowsrv_ServiceDesc is the grpc.ServiceDesc for Flowsrv service.
 // It's only intended for direct use with grpc.RegisterService,
 // and not to be introspected or modified (even as a copy)
 var Flowsrv_ServiceDesc = grpc.ServiceDesc{
 	ServiceName: "pb.Flowsrv",
 	HandlerType: (*FlowsrvServer)(nil),
-	Methods: []grpc.MethodDesc{
-		{
-			MethodName: "disconnect",
-			Handler:    _Flowsrv_Disconnect_Handler,
-		},
-	},
+	Methods:     []grpc.MethodDesc{},
 	Streams: []grpc.StreamDesc{
 		{
 			StreamName:    "connect",