Ai世界玩家人数超过4人测试

This commit is contained in:
flswld
2023-01-10 19:21:56 +08:00
parent 3ecdb6ff70
commit 1793054ef4
22 changed files with 596 additions and 251 deletions

View File

@@ -35,6 +35,8 @@ type DiscoveryNATSRPCServer interface {
GetGateServerAddr(ctx context.Context, req *GetGateServerAddrReq) (*GateServerAddr, error)
// 获取全部网关服务器信息列表
GetAllGateServerInfoList(ctx context.Context, req *NullMsg) (*GateServerInfoList, error)
// 获取主游戏服务器的appid
GetMainGameServerAppId(ctx context.Context, req *NullMsg) (*GetMainGameServerAppIdRsp, error)
}
// RegisterDiscoveryNATSRPCServer register Discovery service
@@ -58,6 +60,8 @@ type DiscoveryNATSRPCClient interface {
GetGateServerAddr(ctx context.Context, req *GetGateServerAddrReq, opt ...natsrpc.CallOption) (*GateServerAddr, error)
// 获取全部网关服务器信息列表
GetAllGateServerInfoList(ctx context.Context, req *NullMsg, opt ...natsrpc.CallOption) (*GateServerInfoList, error)
// 获取主游戏服务器的appid
GetMainGameServerAppId(ctx context.Context, req *NullMsg, opt ...natsrpc.CallOption) (*GetMainGameServerAppIdRsp, error)
}
type _DiscoveryNATSRPCClient struct {
@@ -110,3 +114,8 @@ func (c *_DiscoveryNATSRPCClient) GetAllGateServerInfoList(ctx context.Context,
err := c.c.Request(ctx, "GetAllGateServerInfoList", req, rep, opt...)
return rep, err
}
func (c *_DiscoveryNATSRPCClient) GetMainGameServerAppId(ctx context.Context, req *NullMsg, opt ...natsrpc.CallOption) (*GetMainGameServerAppIdRsp, error) {
rep := &GetMainGameServerAppIdRsp{}
err := c.c.Request(ctx, "GetMainGameServerAppId", req, rep, opt...)
return rep, err
}

View File

@@ -427,6 +427,53 @@ func (x *GetGateServerAddrReq) GetVersion() string {
return ""
}
type GetMainGameServerAppIdRsp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
AppId string `protobuf:"bytes,1,opt,name=app_id,json=appId,proto3" json:"app_id,omitempty"`
}
func (x *GetMainGameServerAppIdRsp) Reset() {
*x = GetMainGameServerAppIdRsp{}
if protoimpl.UnsafeEnabled {
mi := &file_api_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetMainGameServerAppIdRsp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetMainGameServerAppIdRsp) ProtoMessage() {}
func (x *GetMainGameServerAppIdRsp) ProtoReflect() protoreflect.Message {
mi := &file_api_proto_msgTypes[8]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetMainGameServerAppIdRsp.ProtoReflect.Descriptor instead.
func (*GetMainGameServerAppIdRsp) Descriptor() ([]byte, []int) {
return file_api_proto_rawDescGZIP(), []int{8}
}
func (x *GetMainGameServerAppIdRsp) GetAppId() string {
if x != nil {
return x.AppId
}
return ""
}
type RegionEc2B struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@@ -438,7 +485,7 @@ type RegionEc2B struct {
func (x *RegionEc2B) Reset() {
*x = RegionEc2B{}
if protoimpl.UnsafeEnabled {
mi := &file_api_proto_msgTypes[8]
mi := &file_api_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -451,7 +498,7 @@ func (x *RegionEc2B) String() string {
func (*RegionEc2B) ProtoMessage() {}
func (x *RegionEc2B) ProtoReflect() protoreflect.Message {
mi := &file_api_proto_msgTypes[8]
mi := &file_api_proto_msgTypes[9]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -464,7 +511,7 @@ func (x *RegionEc2B) ProtoReflect() protoreflect.Message {
// Deprecated: Use RegionEc2B.ProtoReflect.Descriptor instead.
func (*RegionEc2B) Descriptor() ([]byte, []int) {
return file_api_proto_rawDescGZIP(), []int{8}
return file_api_proto_rawDescGZIP(), []int{9}
}
func (x *RegionEc2B) GetData() []byte {
@@ -488,7 +535,7 @@ type GateServerAddr struct {
func (x *GateServerAddr) Reset() {
*x = GateServerAddr{}
if protoimpl.UnsafeEnabled {
mi := &file_api_proto_msgTypes[9]
mi := &file_api_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -501,7 +548,7 @@ func (x *GateServerAddr) String() string {
func (*GateServerAddr) ProtoMessage() {}
func (x *GateServerAddr) ProtoReflect() protoreflect.Message {
mi := &file_api_proto_msgTypes[9]
mi := &file_api_proto_msgTypes[10]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -514,7 +561,7 @@ func (x *GateServerAddr) ProtoReflect() protoreflect.Message {
// Deprecated: Use GateServerAddr.ProtoReflect.Descriptor instead.
func (*GateServerAddr) Descriptor() ([]byte, []int) {
return file_api_proto_rawDescGZIP(), []int{9}
return file_api_proto_rawDescGZIP(), []int{10}
}
func (x *GateServerAddr) GetKcpAddr() string {
@@ -558,7 +605,7 @@ type GateServerInfo struct {
func (x *GateServerInfo) Reset() {
*x = GateServerInfo{}
if protoimpl.UnsafeEnabled {
mi := &file_api_proto_msgTypes[10]
mi := &file_api_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -571,7 +618,7 @@ func (x *GateServerInfo) String() string {
func (*GateServerInfo) ProtoMessage() {}
func (x *GateServerInfo) ProtoReflect() protoreflect.Message {
mi := &file_api_proto_msgTypes[10]
mi := &file_api_proto_msgTypes[11]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -584,7 +631,7 @@ func (x *GateServerInfo) ProtoReflect() protoreflect.Message {
// Deprecated: Use GateServerInfo.ProtoReflect.Descriptor instead.
func (*GateServerInfo) Descriptor() ([]byte, []int) {
return file_api_proto_rawDescGZIP(), []int{10}
return file_api_proto_rawDescGZIP(), []int{11}
}
func (x *GateServerInfo) GetAppId() string {
@@ -619,7 +666,7 @@ type GateServerInfoList struct {
func (x *GateServerInfoList) Reset() {
*x = GateServerInfoList{}
if protoimpl.UnsafeEnabled {
mi := &file_api_proto_msgTypes[11]
mi := &file_api_proto_msgTypes[12]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -632,7 +679,7 @@ func (x *GateServerInfoList) String() string {
func (*GateServerInfoList) ProtoMessage() {}
func (x *GateServerInfoList) ProtoReflect() protoreflect.Message {
mi := &file_api_proto_msgTypes[11]
mi := &file_api_proto_msgTypes[12]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -645,7 +692,7 @@ func (x *GateServerInfoList) ProtoReflect() protoreflect.Message {
// Deprecated: Use GateServerInfoList.ProtoReflect.Descriptor instead.
func (*GateServerInfoList) Descriptor() ([]byte, []int) {
return file_api_proto_rawDescGZIP(), []int{11}
return file_api_proto_rawDescGZIP(), []int{12}
}
func (x *GateServerInfoList) GetGateServerInfoList() []*GateServerInfo {
@@ -692,63 +739,71 @@ var file_api_proto_rawDesc = []byte{
0x64, 0x22, 0x30, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x47, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76,
0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72,
0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73,
0x69, 0x6f, 0x6e, 0x22, 0x20, 0x0a, 0x0a, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x45, 0x63, 0x32,
0x62, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52,
0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x78, 0x0a, 0x0e, 0x47, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72,
0x76, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x12, 0x19, 0x0a, 0x08, 0x6b, 0x63, 0x70, 0x5f, 0x61,
0x64, 0x64, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6b, 0x63, 0x70, 0x41, 0x64,
0x64, 0x72, 0x12, 0x19, 0x0a, 0x08, 0x6b, 0x63, 0x70, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02,
0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x6b, 0x63, 0x70, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x17, 0x0a,
0x07, 0x6d, 0x71, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06,
0x6d, 0x71, 0x41, 0x64, 0x64, 0x72, 0x12, 0x17, 0x0a, 0x07, 0x6d, 0x71, 0x5f, 0x70, 0x6f, 0x72,
0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x6d, 0x71, 0x50, 0x6f, 0x72, 0x74, 0x22,
0x59, 0x0a, 0x0e, 0x47, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x6e, 0x66,
0x6f, 0x12, 0x15, 0x0a, 0x06, 0x61, 0x70, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x6d, 0x71, 0x5f, 0x61,
0x64, 0x64, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x71, 0x41, 0x64, 0x64,
0x72, 0x12, 0x17, 0x0a, 0x07, 0x6d, 0x71, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01,
0x28, 0x0d, 0x52, 0x06, 0x6d, 0x71, 0x50, 0x6f, 0x72, 0x74, 0x22, 0x61, 0x0a, 0x12, 0x47, 0x61,
0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74,
0x12, 0x4b, 0x0a, 0x15, 0x67, 0x61, 0x74, 0x65, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f,
0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32,
0x18, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x61, 0x74, 0x65, 0x53,
0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x12, 0x67, 0x61, 0x74, 0x65, 0x53,
0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x32, 0x89, 0x04,
0x0a, 0x09, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x12, 0x4c, 0x0a, 0x0e, 0x52,
0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x1b, 0x2e,
0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65,
0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x6e, 0x6f, 0x64,
0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x53, 0x65,
0x72, 0x76, 0x65, 0x72, 0x52, 0x73, 0x70, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x0c, 0x43, 0x61, 0x6e,
0x63, 0x65, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x19, 0x2e, 0x6e, 0x6f, 0x64, 0x65,
0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x65,
0x72, 0x52, 0x65, 0x71, 0x1a, 0x11, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e,
0x4e, 0x75, 0x6c, 0x6c, 0x4d, 0x73, 0x67, 0x22, 0x00, 0x12, 0x44, 0x0a, 0x0f, 0x4b, 0x65, 0x65,
0x70, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x1c, 0x2e, 0x6e,
0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4b, 0x65, 0x65, 0x70, 0x61, 0x6c, 0x69, 0x76,
0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x11, 0x2e, 0x6e, 0x6f, 0x64,
0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4e, 0x75, 0x6c, 0x6c, 0x4d, 0x73, 0x67, 0x22, 0x00, 0x12,
0x4c, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x70, 0x70, 0x49,
0x64, 0x12, 0x1b, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74,
0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x70, 0x70, 0x49, 0x64, 0x52, 0x65, 0x71, 0x1a, 0x1b,
0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72,
0x76, 0x65, 0x72, 0x41, 0x70, 0x70, 0x49, 0x64, 0x52, 0x73, 0x70, 0x22, 0x00, 0x12, 0x3a, 0x0a,
0x0d, 0x47, 0x65, 0x74, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x45, 0x63, 0x32, 0x62, 0x12, 0x11,
0x69, 0x6f, 0x6e, 0x22, 0x32, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x4d, 0x61, 0x69, 0x6e, 0x47, 0x61,
0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x70, 0x70, 0x49, 0x64, 0x52, 0x73, 0x70,
0x12, 0x15, 0x0a, 0x06, 0x61, 0x70, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x22, 0x20, 0x0a, 0x0a, 0x52, 0x65, 0x67, 0x69, 0x6f,
0x6e, 0x45, 0x63, 0x32, 0x62, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20,
0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x78, 0x0a, 0x0e, 0x47, 0x61, 0x74,
0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x12, 0x19, 0x0a, 0x08, 0x6b,
0x63, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6b,
0x63, 0x70, 0x41, 0x64, 0x64, 0x72, 0x12, 0x19, 0x0a, 0x08, 0x6b, 0x63, 0x70, 0x5f, 0x70, 0x6f,
0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x6b, 0x63, 0x70, 0x50, 0x6f, 0x72,
0x74, 0x12, 0x17, 0x0a, 0x07, 0x6d, 0x71, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x03, 0x20, 0x01,
0x28, 0x09, 0x52, 0x06, 0x6d, 0x71, 0x41, 0x64, 0x64, 0x72, 0x12, 0x17, 0x0a, 0x07, 0x6d, 0x71,
0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x6d, 0x71, 0x50,
0x6f, 0x72, 0x74, 0x22, 0x59, 0x0a, 0x0e, 0x47, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65,
0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x15, 0x0a, 0x06, 0x61, 0x70, 0x70, 0x5f, 0x69, 0x64, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07,
0x6d, 0x71, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d,
0x71, 0x41, 0x64, 0x64, 0x72, 0x12, 0x17, 0x0a, 0x07, 0x6d, 0x71, 0x5f, 0x70, 0x6f, 0x72, 0x74,
0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x6d, 0x71, 0x50, 0x6f, 0x72, 0x74, 0x22, 0x61,
0x0a, 0x12, 0x47, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f,
0x4c, 0x69, 0x73, 0x74, 0x12, 0x4b, 0x0a, 0x15, 0x67, 0x61, 0x74, 0x65, 0x5f, 0x73, 0x65, 0x72,
0x76, 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20,
0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47,
0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x12, 0x67,
0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73,
0x74, 0x32, 0xdd, 0x04, 0x0a, 0x09, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x12,
0x4c, 0x0a, 0x0e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65,
0x72, 0x12, 0x1b, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67,
0x69, 0x73, 0x74, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x1b,
0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74,
0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x73, 0x70, 0x22, 0x00, 0x12, 0x3e, 0x0a,
0x0c, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x19, 0x2e,
0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x53,
0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x11, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e,
0x61, 0x70, 0x69, 0x2e, 0x4e, 0x75, 0x6c, 0x6c, 0x4d, 0x73, 0x67, 0x22, 0x00, 0x12, 0x44, 0x0a,
0x0f, 0x4b, 0x65, 0x65, 0x70, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72,
0x12, 0x1c, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4b, 0x65, 0x65, 0x70,
0x61, 0x6c, 0x69, 0x76, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x11,
0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4e, 0x75, 0x6c, 0x6c, 0x4d, 0x73,
0x67, 0x1a, 0x14, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67,
0x69, 0x6f, 0x6e, 0x45, 0x63, 0x32, 0x62, 0x22, 0x00, 0x12, 0x4f, 0x0a, 0x11, 0x47, 0x65, 0x74,
0x47, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x12, 0x1e,
0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x47, 0x61, 0x74,
0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x18,
0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x61, 0x74, 0x65, 0x53, 0x65,
0x72, 0x76, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x22, 0x00, 0x12, 0x4d, 0x0a, 0x18, 0x47, 0x65,
0x74, 0x41, 0x6c, 0x6c, 0x47, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x6e,
0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x11, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70,
0x69, 0x2e, 0x4e, 0x75, 0x6c, 0x6c, 0x4d, 0x73, 0x67, 0x1a, 0x1c, 0x2e, 0x6e, 0x6f, 0x64, 0x65,
0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49,
0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x00, 0x42, 0x13, 0x5a, 0x11, 0x68, 0x6b, 0x34,
0x65, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x3b, 0x61, 0x70, 0x69, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x67, 0x22, 0x00, 0x12, 0x4c, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72,
0x41, 0x70, 0x70, 0x49, 0x64, 0x12, 0x1b, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69,
0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x70, 0x70, 0x49, 0x64, 0x52,
0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65,
0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x70, 0x70, 0x49, 0x64, 0x52, 0x73, 0x70, 0x22,
0x00, 0x12, 0x3a, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x45, 0x63,
0x32, 0x62, 0x12, 0x11, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4e, 0x75,
0x6c, 0x6c, 0x4d, 0x73, 0x67, 0x1a, 0x14, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69,
0x2e, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x45, 0x63, 0x32, 0x62, 0x22, 0x00, 0x12, 0x4f, 0x0a,
0x11, 0x47, 0x65, 0x74, 0x47, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x64,
0x64, 0x72, 0x12, 0x1e, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65,
0x74, 0x47, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x52,
0x65, 0x71, 0x1a, 0x18, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x61,
0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x22, 0x00, 0x12, 0x4d,
0x0a, 0x18, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x47, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76,
0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x11, 0x2e, 0x6e, 0x6f, 0x64,
0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4e, 0x75, 0x6c, 0x6c, 0x4d, 0x73, 0x67, 0x1a, 0x1c, 0x2e,
0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72,
0x76, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x00, 0x12, 0x52, 0x0a,
0x16, 0x47, 0x65, 0x74, 0x4d, 0x61, 0x69, 0x6e, 0x47, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76,
0x65, 0x72, 0x41, 0x70, 0x70, 0x49, 0x64, 0x12, 0x11, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61,
0x70, 0x69, 0x2e, 0x4e, 0x75, 0x6c, 0x6c, 0x4d, 0x73, 0x67, 0x1a, 0x23, 0x2e, 0x6e, 0x6f, 0x64,
0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x4d, 0x61, 0x69, 0x6e, 0x47, 0x61, 0x6d,
0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x70, 0x70, 0x49, 0x64, 0x52, 0x73, 0x70, 0x22,
0x00, 0x42, 0x13, 0x5a, 0x11, 0x68, 0x6b, 0x34, 0x65, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x61,
0x70, 0x69, 0x3b, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -763,24 +818,25 @@ func file_api_proto_rawDescGZIP() []byte {
return file_api_proto_rawDescData
}
var file_api_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
var file_api_proto_msgTypes = make([]protoimpl.MessageInfo, 13)
var file_api_proto_goTypes = []interface{}{
(*NullMsg)(nil), // 0: node.api.NullMsg
(*GetServerAppIdReq)(nil), // 1: node.api.GetServerAppIdReq
(*GetServerAppIdRsp)(nil), // 2: node.api.GetServerAppIdRsp
(*RegisterServerReq)(nil), // 3: node.api.RegisterServerReq
(*RegisterServerRsp)(nil), // 4: node.api.RegisterServerRsp
(*CancelServerReq)(nil), // 5: node.api.CancelServerReq
(*KeepaliveServerReq)(nil), // 6: node.api.KeepaliveServerReq
(*GetGateServerAddrReq)(nil), // 7: node.api.GetGateServerAddrReq
(*RegionEc2B)(nil), // 8: node.api.RegionEc2b
(*GateServerAddr)(nil), // 9: node.api.GateServerAddr
(*GateServerInfo)(nil), // 10: node.api.GateServerInfo
(*GateServerInfoList)(nil), // 11: node.api.GateServerInfoList
(*NullMsg)(nil), // 0: node.api.NullMsg
(*GetServerAppIdReq)(nil), // 1: node.api.GetServerAppIdReq
(*GetServerAppIdRsp)(nil), // 2: node.api.GetServerAppIdRsp
(*RegisterServerReq)(nil), // 3: node.api.RegisterServerReq
(*RegisterServerRsp)(nil), // 4: node.api.RegisterServerRsp
(*CancelServerReq)(nil), // 5: node.api.CancelServerReq
(*KeepaliveServerReq)(nil), // 6: node.api.KeepaliveServerReq
(*GetGateServerAddrReq)(nil), // 7: node.api.GetGateServerAddrReq
(*GetMainGameServerAppIdRsp)(nil), // 8: node.api.GetMainGameServerAppIdRsp
(*RegionEc2B)(nil), // 9: node.api.RegionEc2b
(*GateServerAddr)(nil), // 10: node.api.GateServerAddr
(*GateServerInfo)(nil), // 11: node.api.GateServerInfo
(*GateServerInfoList)(nil), // 12: node.api.GateServerInfoList
}
var file_api_proto_depIdxs = []int32{
9, // 0: node.api.RegisterServerReq.gate_server_addr:type_name -> node.api.GateServerAddr
10, // 1: node.api.GateServerInfoList.gate_server_info_list:type_name -> node.api.GateServerInfo
10, // 0: node.api.RegisterServerReq.gate_server_addr:type_name -> node.api.GateServerAddr
11, // 1: node.api.GateServerInfoList.gate_server_info_list:type_name -> node.api.GateServerInfo
3, // 2: node.api.Discovery.RegisterServer:input_type -> node.api.RegisterServerReq
5, // 3: node.api.Discovery.CancelServer:input_type -> node.api.CancelServerReq
6, // 4: node.api.Discovery.KeepaliveServer:input_type -> node.api.KeepaliveServerReq
@@ -788,15 +844,17 @@ var file_api_proto_depIdxs = []int32{
0, // 6: node.api.Discovery.GetRegionEc2b:input_type -> node.api.NullMsg
7, // 7: node.api.Discovery.GetGateServerAddr:input_type -> node.api.GetGateServerAddrReq
0, // 8: node.api.Discovery.GetAllGateServerInfoList:input_type -> node.api.NullMsg
4, // 9: node.api.Discovery.RegisterServer:output_type -> node.api.RegisterServerRsp
0, // 10: node.api.Discovery.CancelServer:output_type -> node.api.NullMsg
0, // 11: node.api.Discovery.KeepaliveServer:output_type -> node.api.NullMsg
2, // 12: node.api.Discovery.GetServerAppId:output_type -> node.api.GetServerAppIdRsp
8, // 13: node.api.Discovery.GetRegionEc2b:output_type -> node.api.RegionEc2b
9, // 14: node.api.Discovery.GetGateServerAddr:output_type -> node.api.GateServerAddr
11, // 15: node.api.Discovery.GetAllGateServerInfoList:output_type -> node.api.GateServerInfoList
9, // [9:16] is the sub-list for method output_type
2, // [2:9] is the sub-list for method input_type
0, // 9: node.api.Discovery.GetMainGameServerAppId:input_type -> node.api.NullMsg
4, // 10: node.api.Discovery.RegisterServer:output_type -> node.api.RegisterServerRsp
0, // 11: node.api.Discovery.CancelServer:output_type -> node.api.NullMsg
0, // 12: node.api.Discovery.KeepaliveServer:output_type -> node.api.NullMsg
2, // 13: node.api.Discovery.GetServerAppId:output_type -> node.api.GetServerAppIdRsp
9, // 14: node.api.Discovery.GetRegionEc2b:output_type -> node.api.RegionEc2b
10, // 15: node.api.Discovery.GetGateServerAddr:output_type -> node.api.GateServerAddr
12, // 16: node.api.Discovery.GetAllGateServerInfoList:output_type -> node.api.GateServerInfoList
8, // 17: node.api.Discovery.GetMainGameServerAppId:output_type -> node.api.GetMainGameServerAppIdRsp
10, // [10:18] is the sub-list for method output_type
2, // [2:10] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
@@ -905,7 +963,7 @@ func file_api_proto_init() {
}
}
file_api_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RegionEc2B); i {
switch v := v.(*GetMainGameServerAppIdRsp); i {
case 0:
return &v.state
case 1:
@@ -917,7 +975,7 @@ func file_api_proto_init() {
}
}
file_api_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GateServerAddr); i {
switch v := v.(*RegionEc2B); i {
case 0:
return &v.state
case 1:
@@ -929,7 +987,7 @@ func file_api_proto_init() {
}
}
file_api_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GateServerInfo); i {
switch v := v.(*GateServerAddr); i {
case 0:
return &v.state
case 1:
@@ -941,6 +999,18 @@ func file_api_proto_init() {
}
}
file_api_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GateServerInfo); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_api_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GateServerInfoList); i {
case 0:
return &v.state
@@ -959,7 +1029,7 @@ func file_api_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_api_proto_rawDesc,
NumEnums: 0,
NumMessages: 12,
NumMessages: 13,
NumExtensions: 0,
NumServices: 1,
},

View File

@@ -19,6 +19,8 @@ service Discovery {
rpc GetGateServerAddr (GetGateServerAddrReq) returns (GateServerAddr) {}
// 获取全部网关服务器信息列表
rpc GetAllGateServerInfoList (NullMsg) returns (GateServerInfoList) {}
// 获取主游戏服务器的appid
rpc GetMainGameServerAppId (NullMsg) returns (GetMainGameServerAppIdRsp) {}
}
message NullMsg {
@@ -57,6 +59,10 @@ message GetGateServerAddrReq {
string version = 1;
}
message GetMainGameServerAppIdRsp {
string app_id = 1;
}
message RegionEc2b {
bytes data = 1;
}

View File

@@ -16,6 +16,10 @@ import (
"github.com/pkg/errors"
)
const (
MaxGsId = 1000
)
var _ api.DiscoveryNATSRPCServer = (*DiscoveryService)(nil)
type ServerInstanceSortList []*ServerInstance
@@ -41,6 +45,7 @@ type ServerInstance struct {
gateServerMqPort uint32
version string
lastAliveTime int64
gsId uint32
}
type DiscoveryService struct {
@@ -100,7 +105,12 @@ func (s *DiscoveryService) RegisterServer(ctx context.Context, req *api.Register
AppId: appId,
}
if req.ServerType == api.GS {
rsp.GsId = atomic.AddUint32(&s.gsIdCounter, 1)
gsId := atomic.AddUint32(&s.gsIdCounter, 1)
if gsId > MaxGsId {
return nil, errors.New("above max gs count")
}
inst.gsId = gsId
rsp.GsId = gsId
}
return rsp, nil
}
@@ -218,6 +228,34 @@ func (s *DiscoveryService) GetAllGateServerInfoList(ctx context.Context, req *ap
}, nil
}
// GetMainGameServerAppId 获取主游戏服务器的appid
func (s *DiscoveryService) GetMainGameServerAppId(ctx context.Context, req *api.NullMsg) (*api.GetMainGameServerAppIdRsp, error) {
logger.Debug("get main game server appid")
instMap, exist := s.serverInstanceMap[api.GS]
if !exist {
return nil, errors.New("game server not exist")
}
if s.getServerInstanceMapLen(instMap) == 0 {
return nil, errors.New("no game server found")
}
appid := ""
minGsId := uint32(MaxGsId)
instMap.Range(func(key, value any) bool {
serverInstance := value.(*ServerInstance)
if serverInstance.gsId < minGsId {
minGsId = serverInstance.gsId
appid = serverInstance.appId
}
return true
})
if appid == "" {
return nil, errors.New("main game server not found")
}
return &api.GetMainGameServerAppIdRsp{
AppId: appid,
}, nil
}
func (s *DiscoveryService) getRandomServerInstance(instMap *sync.Map) *ServerInstance {
instList := make(ServerInstanceSortList, 0)
instMap.Range(func(key, value any) bool {