diff --git a/Makefile b/Makefile index 3a3c03d..540a718 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ pname = plugin-$(IMGTIME).so gen: protoc -I./protos --go_out=./protos --go-grpc_out=./protos ./protos/*proto - protoc-go-inject-tag -input=./protos/pb/*.pb.go + protoc-go-inject-tag -input=./pb/*.pb.go test: go run test/client.go diff --git a/cmd/game.go b/cmd/game.go index d650402..06bd2d3 100644 --- a/cmd/game.go +++ b/cmd/game.go @@ -1,6 +1,7 @@ package main import ( + _ "net/http/pprof" "os" "os/signal" "pro2d/conf" diff --git a/pb/account.pb.go b/pb/account.pb.go new file mode 100644 index 0000000..965f141 --- /dev/null +++ b/pb/account.pb.go @@ -0,0 +1,316 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v3.17.3 +// source: account.proto + +package pb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ServiceInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` +} + +func (x *ServiceInfo) Reset() { + *x = ServiceInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_account_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ServiceInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServiceInfo) ProtoMessage() {} + +func (x *ServiceInfo) ProtoReflect() protoreflect.Message { + mi := &file_account_proto_msgTypes[0] + 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 ServiceInfo.ProtoReflect.Descriptor instead. +func (*ServiceInfo) Descriptor() ([]byte, []int) { + return file_account_proto_rawDescGZIP(), []int{0} +} + +func (x *ServiceInfo) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *ServiceInfo) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *ServiceInfo) GetAddress() string { + if x != nil { + return x.Address + } + return "" +} + +type LoginRsp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid,omitempty"` + GameService []*ServiceInfo `protobuf:"bytes,2,rep,name=game_service,json=gameService,proto3" json:"game_service,omitempty"` +} + +func (x *LoginRsp) Reset() { + *x = LoginRsp{} + if protoimpl.UnsafeEnabled { + mi := &file_account_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LoginRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoginRsp) ProtoMessage() {} + +func (x *LoginRsp) ProtoReflect() protoreflect.Message { + mi := &file_account_proto_msgTypes[1] + 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 LoginRsp.ProtoReflect.Descriptor instead. +func (*LoginRsp) Descriptor() ([]byte, []int) { + return file_account_proto_rawDescGZIP(), []int{1} +} + +func (x *LoginRsp) GetUid() string { + if x != nil { + return x.Uid + } + return "" +} + +func (x *LoginRsp) GetGameService() []*ServiceInfo { + if x != nil { + return x.GameService + } + return nil +} + +type Register struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Phone string `protobuf:"bytes,1,opt,name=phone,proto3" json:"phone,omitempty" binding:"required"` // @inject_tag: binding:"required" + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty" binding:"required"` // @inject_tag: binding:"required" + Code int32 `protobuf:"varint,3,opt,name=code,proto3" json:"code,omitempty" binding:"required"` // @inject_tag: binding:"required" +} + +func (x *Register) Reset() { + *x = Register{} + if protoimpl.UnsafeEnabled { + mi := &file_account_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Register) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Register) ProtoMessage() {} + +func (x *Register) ProtoReflect() protoreflect.Message { + mi := &file_account_proto_msgTypes[2] + 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 Register.ProtoReflect.Descriptor instead. +func (*Register) Descriptor() ([]byte, []int) { + return file_account_proto_rawDescGZIP(), []int{2} +} + +func (x *Register) GetPhone() string { + if x != nil { + return x.Phone + } + return "" +} + +func (x *Register) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +func (x *Register) GetCode() int32 { + if x != nil { + return x.Code + } + return 0 +} + +var File_account_proto protoreflect.FileDescriptor + +var file_account_proto_rawDesc = []byte{ + 0x0a, 0x0d, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x4b, 0x0a, 0x0b, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x55, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x73, + 0x70, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x75, 0x69, 0x64, 0x12, 0x37, 0x0a, 0x0c, 0x67, 0x61, 0x6d, 0x65, 0x5f, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x61, 0x63, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, + 0x0b, 0x67, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x22, 0x50, 0x0a, 0x08, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x6e, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x1a, + 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, + 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x42, 0x0a, + 0x5a, 0x08, 0x2e, 0x2e, 0x2f, 0x70, 0x62, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, +} + +var ( + file_account_proto_rawDescOnce sync.Once + file_account_proto_rawDescData = file_account_proto_rawDesc +) + +func file_account_proto_rawDescGZIP() []byte { + file_account_proto_rawDescOnce.Do(func() { + file_account_proto_rawDescData = protoimpl.X.CompressGZIP(file_account_proto_rawDescData) + }) + return file_account_proto_rawDescData +} + +var file_account_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_account_proto_goTypes = []interface{}{ + (*ServiceInfo)(nil), // 0: account.ServiceInfo + (*LoginRsp)(nil), // 1: account.LoginRsp + (*Register)(nil), // 2: account.Register +} +var file_account_proto_depIdxs = []int32{ + 0, // 0: account.LoginRsp.game_service:type_name -> account.ServiceInfo + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_account_proto_init() } +func file_account_proto_init() { + if File_account_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_account_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ServiceInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_account_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LoginRsp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_account_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Register); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_account_proto_rawDesc, + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_account_proto_goTypes, + DependencyIndexes: file_account_proto_depIdxs, + MessageInfos: file_account_proto_msgTypes, + }.Build() + File_account_proto = out.File + file_account_proto_rawDesc = nil + file_account_proto_goTypes = nil + file_account_proto_depIdxs = nil +} diff --git a/pb/game.pb.go b/pb/game.pb.go new file mode 100644 index 0000000..937047c --- /dev/null +++ b/pb/game.pb.go @@ -0,0 +1,460 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v3.17.3 +// source: game.proto + +package pb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type HeartReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` +} + +func (x *HeartReq) Reset() { + *x = HeartReq{} + if protoimpl.UnsafeEnabled { + mi := &file_game_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HeartReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HeartReq) ProtoMessage() {} + +func (x *HeartReq) ProtoReflect() protoreflect.Message { + mi := &file_game_proto_msgTypes[0] + 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 HeartReq.ProtoReflect.Descriptor instead. +func (*HeartReq) Descriptor() ([]byte, []int) { + return file_game_proto_rawDescGZIP(), []int{0} +} + +func (x *HeartReq) GetCode() int64 { + if x != nil { + return x.Code + } + return 0 +} + +//ResponseCmd RoleRsp +type LoginReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid,omitempty"` + Device string `protobuf:"bytes,2,opt,name=device,proto3" json:"device,omitempty"` +} + +func (x *LoginReq) Reset() { + *x = LoginReq{} + if protoimpl.UnsafeEnabled { + mi := &file_game_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LoginReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoginReq) ProtoMessage() {} + +func (x *LoginReq) ProtoReflect() protoreflect.Message { + mi := &file_game_proto_msgTypes[1] + 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 LoginReq.ProtoReflect.Descriptor instead. +func (*LoginReq) Descriptor() ([]byte, []int) { + return file_game_proto_rawDescGZIP(), []int{1} +} + +func (x *LoginReq) GetUid() string { + if x != nil { + return x.Uid + } + return "" +} + +func (x *LoginReq) GetDevice() string { + if x != nil { + return x.Device + } + return "" +} + +type LoginResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid,omitempty"` + Device string `protobuf:"bytes,2,opt,name=device,proto3" json:"device,omitempty"` +} + +func (x *LoginResponse) Reset() { + *x = LoginResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_game_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LoginResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoginResponse) ProtoMessage() {} + +func (x *LoginResponse) ProtoReflect() protoreflect.Message { + mi := &file_game_proto_msgTypes[2] + 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 LoginResponse.ProtoReflect.Descriptor instead. +func (*LoginResponse) Descriptor() ([]byte, []int) { + return file_game_proto_rawDescGZIP(), []int{2} +} + +func (x *LoginResponse) GetUid() string { + if x != nil { + return x.Uid + } + return "" +} + +func (x *LoginResponse) GetDevice() string { + if x != nil { + return x.Device + } + return "" +} + +type CreateReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid,omitempty"` + Device string `protobuf:"bytes,2,opt,name=device,proto3" json:"device,omitempty"` +} + +func (x *CreateReq) Reset() { + *x = CreateReq{} + if protoimpl.UnsafeEnabled { + mi := &file_game_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateReq) ProtoMessage() {} + +func (x *CreateReq) ProtoReflect() protoreflect.Message { + mi := &file_game_proto_msgTypes[3] + 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 CreateReq.ProtoReflect.Descriptor instead. +func (*CreateReq) Descriptor() ([]byte, []int) { + return file_game_proto_rawDescGZIP(), []int{3} +} + +func (x *CreateReq) GetUid() string { + if x != nil { + return x.Uid + } + return "" +} + +func (x *CreateReq) GetDevice() string { + if x != nil { + return x.Device + } + return "" +} + +type RoleRsp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Role *Role `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` + Hero []*Hero `protobuf:"bytes,3,rep,name=hero,proto3" json:"hero,omitempty"` + Team *Team `protobuf:"bytes,4,opt,name=team,proto3" json:"team,omitempty"` + Equips []*Equipment `protobuf:"bytes,5,rep,name=equips,proto3" json:"equips,omitempty"` +} + +func (x *RoleRsp) Reset() { + *x = RoleRsp{} + if protoimpl.UnsafeEnabled { + mi := &file_game_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RoleRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RoleRsp) ProtoMessage() {} + +func (x *RoleRsp) ProtoReflect() protoreflect.Message { + mi := &file_game_proto_msgTypes[4] + 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 RoleRsp.ProtoReflect.Descriptor instead. +func (*RoleRsp) Descriptor() ([]byte, []int) { + return file_game_proto_rawDescGZIP(), []int{4} +} + +func (x *RoleRsp) GetRole() *Role { + if x != nil { + return x.Role + } + return nil +} + +func (x *RoleRsp) GetHero() []*Hero { + if x != nil { + return x.Hero + } + return nil +} + +func (x *RoleRsp) GetTeam() *Team { + if x != nil { + return x.Team + } + return nil +} + +func (x *RoleRsp) GetEquips() []*Equipment { + if x != nil { + return x.Equips + } + return nil +} + +var File_game_proto protoreflect.FileDescriptor + +var file_game_proto_rawDesc = []byte{ + 0x0a, 0x0a, 0x67, 0x61, 0x6d, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x67, 0x61, + 0x6d, 0x65, 0x1a, 0x0c, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x22, 0x1e, 0x0a, 0x08, 0x48, 0x65, 0x61, 0x72, 0x74, 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, + 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, + 0x22, 0x34, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, + 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x16, + 0x0a, 0x06, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x22, 0x39, 0x0a, 0x0d, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x65, 0x76, + 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x65, 0x76, 0x69, 0x63, + 0x65, 0x22, 0x35, 0x0a, 0x09, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12, 0x10, + 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, + 0x12, 0x16, 0x0a, 0x06, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x22, 0x9a, 0x01, 0x0a, 0x07, 0x52, 0x6f, 0x6c, + 0x65, 0x52, 0x73, 0x70, 0x12, 0x20, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2e, 0x52, 0x6f, 0x6c, 0x65, + 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x18, 0x03, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2e, 0x48, 0x65, + 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x12, 0x20, 0x0a, 0x04, 0x74, 0x65, 0x61, 0x6d, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2e, + 0x54, 0x65, 0x61, 0x6d, 0x52, 0x04, 0x74, 0x65, 0x61, 0x6d, 0x12, 0x29, 0x0a, 0x06, 0x65, 0x71, + 0x75, 0x69, 0x70, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x6d, 0x6f, 0x64, + 0x65, 0x6c, 0x73, 0x2e, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x06, 0x65, + 0x71, 0x75, 0x69, 0x70, 0x73, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2e, 0x2f, 0x70, 0x62, 0x3b, 0x70, + 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_game_proto_rawDescOnce sync.Once + file_game_proto_rawDescData = file_game_proto_rawDesc +) + +func file_game_proto_rawDescGZIP() []byte { + file_game_proto_rawDescOnce.Do(func() { + file_game_proto_rawDescData = protoimpl.X.CompressGZIP(file_game_proto_rawDescData) + }) + return file_game_proto_rawDescData +} + +var file_game_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_game_proto_goTypes = []interface{}{ + (*HeartReq)(nil), // 0: game.HeartReq + (*LoginReq)(nil), // 1: game.LoginReq + (*LoginResponse)(nil), // 2: game.LoginResponse + (*CreateReq)(nil), // 3: game.CreateReq + (*RoleRsp)(nil), // 4: game.RoleRsp + (*Role)(nil), // 5: models.Role + (*Hero)(nil), // 6: models.Hero + (*Team)(nil), // 7: models.Team + (*Equipment)(nil), // 8: models.Equipment +} +var file_game_proto_depIdxs = []int32{ + 5, // 0: game.RoleRsp.role:type_name -> models.Role + 6, // 1: game.RoleRsp.hero:type_name -> models.Hero + 7, // 2: game.RoleRsp.team:type_name -> models.Team + 8, // 3: game.RoleRsp.equips:type_name -> models.Equipment + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_game_proto_init() } +func file_game_proto_init() { + if File_game_proto != nil { + return + } + file_models_proto_init() + if !protoimpl.UnsafeEnabled { + file_game_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HeartReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_game_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LoginReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_game_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LoginResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_game_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_game_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RoleRsp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_game_proto_rawDesc, + NumEnums: 0, + NumMessages: 5, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_game_proto_goTypes, + DependencyIndexes: file_game_proto_depIdxs, + MessageInfos: file_game_proto_msgTypes, + }.Build() + File_game_proto = out.File + file_game_proto_rawDesc = nil + file_game_proto_goTypes = nil + file_game_proto_depIdxs = nil +} diff --git a/pb/models.pb.go b/pb/models.pb.go new file mode 100644 index 0000000..5220f0b --- /dev/null +++ b/pb/models.pb.go @@ -0,0 +1,676 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v3.17.3 +// source: models.proto + +package pb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Account struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Phone string `protobuf:"bytes,1,opt,name=phone,proto3" json:"phone,omitempty" index:"unique" pri:"1"` // @inject_tag: index:"unique" pri:"1" + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` + Uid string `protobuf:"bytes,3,opt,name=uid,proto3" json:"uid,omitempty"` +} + +func (x *Account) Reset() { + *x = Account{} + if protoimpl.UnsafeEnabled { + mi := &file_models_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Account) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Account) ProtoMessage() {} + +func (x *Account) ProtoReflect() protoreflect.Message { + mi := &file_models_proto_msgTypes[0] + 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 Account.ProtoReflect.Descriptor instead. +func (*Account) Descriptor() ([]byte, []int) { + return file_models_proto_rawDescGZIP(), []int{0} +} + +func (x *Account) GetPhone() string { + if x != nil { + return x.Phone + } + return "" +} + +func (x *Account) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +func (x *Account) GetUid() string { + if x != nil { + return x.Uid + } + return "" +} + +type Hero struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty" index:"unique" pri:"1"` // @inject_tag: index:"unique" pri:"1" + RoleId string `protobuf:"bytes,2,opt,name=role_id,json=roleId,proto3" json:"role_id,omitempty"` + Type int32 `protobuf:"varint,3,opt,name=type,proto3" json:"type,omitempty"` + Level int32 `protobuf:"varint,4,opt,name=level,proto3" json:"level,omitempty"` + ReinCount int32 `protobuf:"varint,5,opt,name=rein_count,json=reinCount,proto3" json:"rein_count,omitempty"` + ReinPoint int32 `protobuf:"varint,6,opt,name=rein_point,json=reinPoint,proto3" json:"rein_point,omitempty"` + Equipments string `protobuf:"bytes,7,opt,name=equipments,proto3" json:"equipments,omitempty"` +} + +func (x *Hero) Reset() { + *x = Hero{} + if protoimpl.UnsafeEnabled { + mi := &file_models_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Hero) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Hero) ProtoMessage() {} + +func (x *Hero) ProtoReflect() protoreflect.Message { + mi := &file_models_proto_msgTypes[1] + 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 Hero.ProtoReflect.Descriptor instead. +func (*Hero) Descriptor() ([]byte, []int) { + return file_models_proto_rawDescGZIP(), []int{1} +} + +func (x *Hero) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *Hero) GetRoleId() string { + if x != nil { + return x.RoleId + } + return "" +} + +func (x *Hero) GetType() int32 { + if x != nil { + return x.Type + } + return 0 +} + +func (x *Hero) GetLevel() int32 { + if x != nil { + return x.Level + } + return 0 +} + +func (x *Hero) GetReinCount() int32 { + if x != nil { + return x.ReinCount + } + return 0 +} + +func (x *Hero) GetReinPoint() int32 { + if x != nil { + return x.ReinPoint + } + return 0 +} + +func (x *Hero) GetEquipments() string { + if x != nil { + return x.Equipments + } + return "" +} + +type Equipment struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty" index:"unique" pri:"1"` // @inject_tag: index:"unique" pri:"1" + RoleId string `protobuf:"bytes,2,opt,name=role_id,json=roleId,proto3" json:"role_id,omitempty"` + Type int64 `protobuf:"varint,3,opt,name=type,proto3" json:"type,omitempty"` + Equip bool `protobuf:"varint,4,opt,name=equip,proto3" json:"equip,omitempty"` + EnhanceLevel bool `protobuf:"varint,5,opt,name=enhance_level,json=enhanceLevel,proto3" json:"enhance_level,omitempty"` +} + +func (x *Equipment) Reset() { + *x = Equipment{} + if protoimpl.UnsafeEnabled { + mi := &file_models_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Equipment) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Equipment) ProtoMessage() {} + +func (x *Equipment) ProtoReflect() protoreflect.Message { + mi := &file_models_proto_msgTypes[2] + 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 Equipment.ProtoReflect.Descriptor instead. +func (*Equipment) Descriptor() ([]byte, []int) { + return file_models_proto_rawDescGZIP(), []int{2} +} + +func (x *Equipment) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *Equipment) GetRoleId() string { + if x != nil { + return x.RoleId + } + return "" +} + +func (x *Equipment) GetType() int64 { + if x != nil { + return x.Type + } + return 0 +} + +func (x *Equipment) GetEquip() bool { + if x != nil { + return x.Equip + } + return false +} + +func (x *Equipment) GetEnhanceLevel() bool { + if x != nil { + return x.EnhanceLevel + } + return false +} + +type Prop struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty" index:"unique" pri:"1"` // @inject_tag: index:"unique" pri:"1" + Count int64 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"` +} + +func (x *Prop) Reset() { + *x = Prop{} + if protoimpl.UnsafeEnabled { + mi := &file_models_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Prop) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Prop) ProtoMessage() {} + +func (x *Prop) ProtoReflect() protoreflect.Message { + mi := &file_models_proto_msgTypes[3] + 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 Prop.ProtoReflect.Descriptor instead. +func (*Prop) Descriptor() ([]byte, []int) { + return file_models_proto_rawDescGZIP(), []int{3} +} + +func (x *Prop) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *Prop) GetCount() int64 { + if x != nil { + return x.Count + } + return 0 +} + +type Team struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty" index:"unique" pri:"1"` // @inject_tag: index:"unique" pri:"1" + HeroIds string `protobuf:"bytes,2,opt,name=hero_ids,json=heroIds,proto3" json:"hero_ids,omitempty"` +} + +func (x *Team) Reset() { + *x = Team{} + if protoimpl.UnsafeEnabled { + mi := &file_models_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Team) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Team) ProtoMessage() {} + +func (x *Team) ProtoReflect() protoreflect.Message { + mi := &file_models_proto_msgTypes[4] + 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 Team.ProtoReflect.Descriptor instead. +func (*Team) Descriptor() ([]byte, []int) { + return file_models_proto_rawDescGZIP(), []int{4} +} + +func (x *Team) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *Team) GetHeroIds() string { + if x != nil { + return x.HeroIds + } + return "" +} + +type Role struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty" index:"unique" pri:"1"` // @inject_tag: index:"unique" pri:"1" + Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid,omitempty" index:"unique"` // @inject_tag: index:"unique" + Device string `protobuf:"bytes,3,opt,name=device,proto3" json:"device,omitempty"` + Nick string `protobuf:"bytes,4,opt,name=nick,proto3" json:"nick,omitempty"` + Level int32 `protobuf:"varint,5,opt,name=level,proto3" json:"level,omitempty"` + Exp int64 `protobuf:"varint,6,opt,name=exp,proto3" json:"exp,omitempty"` + Hp int64 `protobuf:"varint,7,opt,name=hp,proto3" json:"hp,omitempty"` + HpMax int64 `protobuf:"varint,8,opt,name=hp_max,json=hpMax,proto3" json:"hp_max,omitempty"` + BuyR string `protobuf:"bytes,11,opt,name=buy_r,json=buyR,proto3" json:"buy_r,omitempty"` + PayR string `protobuf:"bytes,12,opt,name=pay_r,json=payR,proto3" json:"pay_r,omitempty"` + Del bool `protobuf:"varint,13,opt,name=del,proto3" json:"del,omitempty"` +} + +func (x *Role) Reset() { + *x = Role{} + if protoimpl.UnsafeEnabled { + mi := &file_models_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Role) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Role) ProtoMessage() {} + +func (x *Role) ProtoReflect() protoreflect.Message { + mi := &file_models_proto_msgTypes[5] + 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 Role.ProtoReflect.Descriptor instead. +func (*Role) Descriptor() ([]byte, []int) { + return file_models_proto_rawDescGZIP(), []int{5} +} + +func (x *Role) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *Role) GetUid() string { + if x != nil { + return x.Uid + } + return "" +} + +func (x *Role) GetDevice() string { + if x != nil { + return x.Device + } + return "" +} + +func (x *Role) GetNick() string { + if x != nil { + return x.Nick + } + return "" +} + +func (x *Role) GetLevel() int32 { + if x != nil { + return x.Level + } + return 0 +} + +func (x *Role) GetExp() int64 { + if x != nil { + return x.Exp + } + return 0 +} + +func (x *Role) GetHp() int64 { + if x != nil { + return x.Hp + } + return 0 +} + +func (x *Role) GetHpMax() int64 { + if x != nil { + return x.HpMax + } + return 0 +} + +func (x *Role) GetBuyR() string { + if x != nil { + return x.BuyR + } + return "" +} + +func (x *Role) GetPayR() string { + if x != nil { + return x.PayR + } + return "" +} + +func (x *Role) GetDel() bool { + if x != nil { + return x.Del + } + return false +} + +var File_models_proto protoreflect.FileDescriptor + +var file_models_proto_rawDesc = []byte{ + 0x0a, 0x0c, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, + 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x22, 0x4d, 0x0a, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, + 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, + 0x6f, 0x72, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x03, 0x75, 0x69, 0x64, 0x22, 0xb7, 0x01, 0x0a, 0x04, 0x48, 0x65, 0x72, 0x6f, 0x12, 0x0e, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x17, + 0x0a, 0x07, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x72, 0x6f, 0x6c, 0x65, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6c, + 0x65, 0x76, 0x65, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, + 0x6c, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x69, 0x6e, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x72, 0x65, 0x69, 0x6e, 0x43, 0x6f, 0x75, 0x6e, 0x74, + 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x69, 0x6e, 0x5f, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x72, 0x65, 0x69, 0x6e, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x12, + 0x1e, 0x0a, 0x0a, 0x65, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x07, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, + 0x83, 0x01, 0x0a, 0x09, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x17, 0x0a, + 0x07, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x72, 0x6f, 0x6c, 0x65, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x71, + 0x75, 0x69, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x65, 0x71, 0x75, 0x69, 0x70, + 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x6e, 0x68, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x6c, 0x65, 0x76, 0x65, + 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x65, 0x6e, 0x68, 0x61, 0x6e, 0x63, 0x65, + 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x22, 0x2c, 0x0a, 0x04, 0x50, 0x72, 0x6f, 0x70, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, + 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x22, 0x31, 0x0a, 0x04, 0x54, 0x65, 0x61, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x68, + 0x65, 0x72, 0x6f, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x68, + 0x65, 0x72, 0x6f, 0x49, 0x64, 0x73, 0x22, 0xdf, 0x01, 0x0a, 0x04, 0x52, 0x6f, 0x6c, 0x65, 0x12, + 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, + 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, + 0x64, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x06, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x69, 0x63, + 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x69, 0x63, 0x6b, 0x12, 0x14, 0x0a, + 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x65, + 0x76, 0x65, 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x78, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x03, 0x65, 0x78, 0x70, 0x12, 0x0e, 0x0a, 0x02, 0x68, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x02, 0x68, 0x70, 0x12, 0x15, 0x0a, 0x06, 0x68, 0x70, 0x5f, 0x6d, 0x61, 0x78, 0x18, + 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x68, 0x70, 0x4d, 0x61, 0x78, 0x12, 0x13, 0x0a, 0x05, + 0x62, 0x75, 0x79, 0x5f, 0x72, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x62, 0x75, 0x79, + 0x52, 0x12, 0x13, 0x0a, 0x05, 0x70, 0x61, 0x79, 0x5f, 0x72, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x70, 0x61, 0x79, 0x52, 0x12, 0x10, 0x0a, 0x03, 0x64, 0x65, 0x6c, 0x18, 0x0d, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x03, 0x64, 0x65, 0x6c, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2e, 0x2f, 0x70, + 0x62, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_models_proto_rawDescOnce sync.Once + file_models_proto_rawDescData = file_models_proto_rawDesc +) + +func file_models_proto_rawDescGZIP() []byte { + file_models_proto_rawDescOnce.Do(func() { + file_models_proto_rawDescData = protoimpl.X.CompressGZIP(file_models_proto_rawDescData) + }) + return file_models_proto_rawDescData +} + +var file_models_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_models_proto_goTypes = []interface{}{ + (*Account)(nil), // 0: models.Account + (*Hero)(nil), // 1: models.Hero + (*Equipment)(nil), // 2: models.Equipment + (*Prop)(nil), // 3: models.Prop + (*Team)(nil), // 4: models.Team + (*Role)(nil), // 5: models.Role +} +var file_models_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] 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 +} + +func init() { file_models_proto_init() } +func file_models_proto_init() { + if File_models_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_models_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Account); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_models_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Hero); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_models_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Equipment); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_models_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Prop); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_models_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Team); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_models_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Role); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_models_proto_rawDesc, + NumEnums: 0, + NumMessages: 6, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_models_proto_goTypes, + DependencyIndexes: file_models_proto_depIdxs, + MessageInfos: file_models_proto_msgTypes, + }.Build() + File_models_proto = out.File + file_models_proto_rawDesc = nil + file_models_proto_goTypes = nil + file_models_proto_depIdxs = nil +} diff --git a/pb/protocode.pb.go b/pb/protocode.pb.go new file mode 100644 index 0000000..9b627d6 --- /dev/null +++ b/pb/protocode.pb.go @@ -0,0 +1,139 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v3.17.3 +// source: protocode.proto + +package pb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ProtoCode int32 + +const ( + ProtoCode_UNKNOWN ProtoCode = 0 + ProtoCode_HeartReq ProtoCode = 1 + ProtoCode_LoginReq ProtoCode = 2 + ProtoCode_CreateReq ProtoCode = 3 + ProtoCode_RoleRsp ProtoCode = 4 +) + +// Enum value maps for ProtoCode. +var ( + ProtoCode_name = map[int32]string{ + 0: "UNKNOWN", + 1: "HeartReq", + 2: "LoginReq", + 3: "CreateReq", + 4: "RoleRsp", + } + ProtoCode_value = map[string]int32{ + "UNKNOWN": 0, + "HeartReq": 1, + "LoginReq": 2, + "CreateReq": 3, + "RoleRsp": 4, + } +) + +func (x ProtoCode) Enum() *ProtoCode { + p := new(ProtoCode) + *p = x + return p +} + +func (x ProtoCode) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ProtoCode) Descriptor() protoreflect.EnumDescriptor { + return file_protocode_proto_enumTypes[0].Descriptor() +} + +func (ProtoCode) Type() protoreflect.EnumType { + return &file_protocode_proto_enumTypes[0] +} + +func (x ProtoCode) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ProtoCode.Descriptor instead. +func (ProtoCode) EnumDescriptor() ([]byte, []int) { + return file_protocode_proto_rawDescGZIP(), []int{0} +} + +var File_protocode_proto protoreflect.FileDescriptor + +var file_protocode_proto_rawDesc = []byte{ + 0x0a, 0x0f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x09, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x64, 0x65, 0x2a, 0x50, 0x0a, 0x09, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, + 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x48, 0x65, 0x61, 0x72, 0x74, 0x52, + 0x65, 0x71, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, + 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x10, + 0x03, 0x12, 0x0b, 0x0a, 0x07, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x73, 0x70, 0x10, 0x04, 0x42, 0x0a, + 0x5a, 0x08, 0x2e, 0x2e, 0x2f, 0x70, 0x62, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, +} + +var ( + file_protocode_proto_rawDescOnce sync.Once + file_protocode_proto_rawDescData = file_protocode_proto_rawDesc +) + +func file_protocode_proto_rawDescGZIP() []byte { + file_protocode_proto_rawDescOnce.Do(func() { + file_protocode_proto_rawDescData = protoimpl.X.CompressGZIP(file_protocode_proto_rawDescData) + }) + return file_protocode_proto_rawDescData +} + +var file_protocode_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_protocode_proto_goTypes = []interface{}{ + (ProtoCode)(0), // 0: protocode.ProtoCode +} +var file_protocode_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] 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 +} + +func init() { file_protocode_proto_init() } +func file_protocode_proto_init() { + if File_protocode_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_protocode_proto_rawDesc, + NumEnums: 1, + NumMessages: 0, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_protocode_proto_goTypes, + DependencyIndexes: file_protocode_proto_depIdxs, + EnumInfos: file_protocode_proto_enumTypes, + }.Build() + File_protocode_proto = out.File + file_protocode_proto_rawDesc = nil + file_protocode_proto_goTypes = nil + file_protocode_proto_depIdxs = nil +} diff --git a/protos b/protos index 608828e..7257f0e 160000 --- a/protos +++ b/protos @@ -1 +1 @@ -Subproject commit 608828ec759ed7e958cf63ae557e592c816e45cc +Subproject commit 7257f0e1d7cbce636e95993247107ca58fd5e374 diff --git a/src/actions/AccountAction.go b/src/actions/AccountAction.go index adf5312..482d659 100644 --- a/src/actions/AccountAction.go +++ b/src/actions/AccountAction.go @@ -3,7 +3,7 @@ package actions import ( "github.com/gin-gonic/gin" "pro2d/conf" - "pro2d/protos/pb" + "pro2d/pb" "pro2d/src/components/net" "pro2d/src/models" "pro2d/src/utils" diff --git a/src/components/db/schema.go b/src/components/db/schema.go index 25d82d1..2598094 100644 --- a/src/components/db/schema.go +++ b/src/components/db/schema.go @@ -75,14 +75,14 @@ func (s *Schema) Update() { } } -func (s *Schema) UpdateProperty(key string, val interface{}) { +func (s *Schema) SetProperty(key string, val interface{}) { s.reflectValue.FieldByName(key).Set(reflect.ValueOf(val)) - s.cacheFields[key] = val + s.cacheFields[strings.ToLower(key)] = val } -func (s *Schema) UpdateProperties(properties map[string]interface{}) { +func (s *Schema) SetProperties(properties map[string]interface{}) { for key, val := range properties { s.reflectValue.FieldByName(key).Set(reflect.ValueOf(val)) - s.cacheFields[key] = val + s.cacheFields[strings.ToLower(key)] = val } } \ No newline at end of file diff --git a/src/components/net/conn.go b/src/components/net/conn.go index 05b5fe6..c3bc8f7 100644 --- a/src/components/net/conn.go +++ b/src/components/net/conn.go @@ -133,8 +133,8 @@ func (c *Connection) update() { atomic.StoreInt64(&c.nextCheckTime, nextCheckTime) } - if c.Role != nil { - c.updateFunc <- func() { + c.updateFunc <- func() { + if c.Role != nil { //role 恢复数据 c.Role.OnRecoverTimer(now) } @@ -164,6 +164,10 @@ func (c *Connection) Start() { func (c *Connection) Stop() { logger.Debug("ID: %d close", c.Id) c.Conn.Close() + if c.Role != nil { + c.Role.OnOfflineEvent() + } + c.Server.OnClose(c) } diff --git a/src/components/net/server.go b/src/components/net/server.go index 3aab660..d4ad0fc 100644 --- a/src/components/net/server.go +++ b/src/components/net/server.go @@ -7,7 +7,7 @@ import ( "net" "plugin" "pro2d/conf" - "pro2d/protos/pb" + "pro2d/pb" "pro2d/src/components/db" "pro2d/src/components/etcd" "pro2d/src/components/logger" @@ -51,7 +51,6 @@ func (s *Server) DoMsgHandler(msg *MsgPkg) { } func (s *Server) OnClose(conn *Connection) { - //conn.Stop() s.Clients.Delete(conn.Id) } @@ -124,7 +123,7 @@ func (s *Server)Stop() { s.Clients.Range(func(key, value interface{}) bool { client := value.(*Connection) - client.Stop() + client.Quiting() return true }) diff --git a/src/components/timewheel/timerwheel.go b/src/components/timewheel/timerwheel.go index e6afe63..948b2f2 100644 --- a/src/components/timewheel/timerwheel.go +++ b/src/components/timewheel/timerwheel.go @@ -39,8 +39,6 @@ func (b*bucket) Add(t *timer) { defer b.mu.Unlock() b.timers.PushBack(t) - //t.setBucket(b) - //t.element = e } func (b*bucket) Flush(reinsert func(t *timer)) { @@ -67,6 +65,7 @@ func init() { TimingWheel = NewTimeWheel() TimingWheel.Start() } + type TimeWheel struct { tick time.Duration ticker *time.Ticker diff --git a/src/models/account.go b/src/models/account.go index 4152174..9e95486 100644 --- a/src/models/account.go +++ b/src/models/account.go @@ -1,7 +1,7 @@ package models import ( - "pro2d/protos/pb" + "pro2d/pb" "pro2d/src/components/db" ) diff --git a/src/models/equip.go b/src/models/equip.go index bc9154d..d249e3e 100644 --- a/src/models/equip.go +++ b/src/models/equip.go @@ -1,7 +1,7 @@ package models import ( - "pro2d/protos/pb" + "pro2d/pb" "pro2d/src/components/db" ) diff --git a/src/models/hero.go b/src/models/hero.go index 4c82106..69876c2 100644 --- a/src/models/hero.go +++ b/src/models/hero.go @@ -1,7 +1,7 @@ package models import ( - "pro2d/protos/pb" + "pro2d/pb" "pro2d/src/components/db" ) diff --git a/src/models/init.go b/src/models/init.go index dded13b..2dc6771 100644 --- a/src/models/init.go +++ b/src/models/init.go @@ -1,7 +1,7 @@ package models import ( - "pro2d/protos/pb" + "pro2d/pb" "pro2d/src/components/db" "pro2d/src/components/logger" "pro2d/src/utils" diff --git a/src/models/prop.go b/src/models/prop.go index ae7159f..76632c8 100644 --- a/src/models/prop.go +++ b/src/models/prop.go @@ -1,7 +1,7 @@ package models import ( - "pro2d/protos/pb" + "pro2d/pb" "pro2d/src/components/db" ) diff --git a/src/models/role.go b/src/models/role.go index e19d8ee..2dec556 100644 --- a/src/models/role.go +++ b/src/models/role.go @@ -2,10 +2,11 @@ package models import ( "fmt" - "pro2d/protos/pb" + "pro2d/pb" "pro2d/src/common" "pro2d/src/components/db" "pro2d/src/components/logger" + "pro2d/src/utils" "sync/atomic" ) @@ -92,6 +93,9 @@ func (m *RoleModel) LoadAll() { m.LoadEquips() } +func (m *RoleModel) updateProperty(property map[string]interface{}) { +} + func (m *RoleModel) AddHero(hero *pb.Hero) { h := NewHero(hero.Id) h.Hero = hero @@ -111,6 +115,11 @@ func (m *RoleModel) OnRecoverTimer(now int64) { m.saveRoleData(now) } +func (m *RoleModel) OnOfflineEvent() { + // 设置最新的登录时间 + m.saveRoleData(utils.Timex()) +} + func (m *RoleModel) saveRoleData(now int64) { if now - m.lastSaveTs < common.SaveDataInterval { return diff --git a/src/models/role_test.go b/src/models/role_test.go index 5125ec3..f88cc70 100644 --- a/src/models/role_test.go +++ b/src/models/role_test.go @@ -3,7 +3,7 @@ package models import ( "fmt" _ "pro2d/conf" - "pro2d/protos/pb" + "pro2d/pb" "pro2d/src/components/db" "pro2d/src/components/logger" "pro2d/src/utils" @@ -26,7 +26,7 @@ func TestNewRole(t *testing.T) { // ReinPoint: 0, // Equipments: "", //}) - role.UpdateProperty("Device", "999999999") + role.SetProperty("Device", "1111") //role.Save() }else { //uid不存在,创建角色 diff --git a/src/models/team.go b/src/models/team.go index 73234e0..67da3a7 100644 --- a/src/models/team.go +++ b/src/models/team.go @@ -1,7 +1,7 @@ package models import ( - "pro2d/protos/pb" + "pro2d/pb" "pro2d/src/components/db" ) diff --git a/src/plugin/RolePlugin.go b/src/plugin/RolePlugin.go index cf3bbd3..d3852a7 100644 --- a/src/plugin/RolePlugin.go +++ b/src/plugin/RolePlugin.go @@ -3,7 +3,7 @@ package plugin import ( "github.com/golang/protobuf/proto" "pro2d/conf" - "pro2d/protos/pb" + "pro2d/pb" "pro2d/src/components/logger" "pro2d/src/components/net" "pro2d/src/models" @@ -46,14 +46,9 @@ func LoginRpc(msg *net.MsgPkg) (int32, proto.Message) { if role == nil { return 2, nil } - role.UpdateProperty("Device", req.Device) + role.SetProperty("Device", req.Device) + - //return 0, &pb.RoleRsp{ - // Role: role.Role, - // Hero: nil, - // Team: nil, - // Equips: nil, - //} msg.Conn.Role = role return 0, &pb.RoleRsp{ Role: role.Role, diff --git a/src/plugin/protocode.go b/src/plugin/protocode.go index 92a9c30..bba508a 100644 --- a/src/plugin/protocode.go +++ b/src/plugin/protocode.go @@ -1,7 +1,7 @@ package plugin import ( - "pro2d/protos/pb" + "pro2d/pb" "pro2d/src/components/logger" "pro2d/src/components/net" ) diff --git a/test/client.go b/test/client.go index 7066ce5..797784a 100644 --- a/test/client.go +++ b/test/client.go @@ -6,7 +6,7 @@ import ( "encoding/binary" "github.com/golang/protobuf/proto" "net" - "pro2d/protos/pb" + "pro2d/pb" "pro2d/src/components/logger" net2 "pro2d/src/components/net" "time" diff --git a/test/client_test.go b/test/client_test.go new file mode 100644 index 0000000..e72e7ab --- /dev/null +++ b/test/client_test.go @@ -0,0 +1,32 @@ +package main + +import ( + "testing" +) + +type Error struct { + errCode uint8 +} +func (e *Error) Error() string { + switch e.errCode { + case 1: + return "file not found" + case 2: + return "time out" + case 3: + return "permission denied" + default: + return "unknown error" + } +} + +func checkError(err error) { + if err != nil { + panic(err) + } +} + +func TestStart( t *testing.T) { + var e *Error + checkError(e) +} \ No newline at end of file diff --git a/tools/protostostruct.go b/tools/protostostruct.go index da19c7e..9bfa6af 100644 --- a/tools/protostostruct.go +++ b/tools/protostostruct.go @@ -15,7 +15,7 @@ var ( ProtoCodeLineReq = "\t%sReq = %d;\n" ProtoCodeLineRsp = "\t%sRsp = %d;\n" - GoProtoCodeStr = "package main\n\nimport (\n\t\"pro2d/protos/pb\"\n\t\"pro2d/src/components/logger\"\n\t\"pro2d/src/components/net\"\n)\n\nfunc init() {\n\tlogger.Debug(\"init protocode...\")\n\tnet.ActionMap = make(map[pb.ProtoCode]net.ActionHandler)\n\n%s\n}\n" + GoProtoCodeStr = "package main\n\nimport (\n\t\"pro2d/pb\"\n\t\"pro2d/src/components/logger\"\n\t\"pro2d/src/components/net\"\n)\n\nfunc init() {\n\tlogger.Debug(\"init protocode...\")\n\tnet.ActionMap = make(map[pb.ProtoCode]net.ActionHandler)\n\n%s\n}\n" GoProtoCodeLine = "\tnet.ActionMap[pb.ProtoCode_%sReq] = %sRpc\n" ) -- libgit2 0.21.2