Gogs 4 mesi fa
parent
commit
43e81820ea
5 ha cambiato i file con 395 aggiunte e 5 eliminazioni
  1. 2 0
      bin/client_msg/common.proto
  2. 1 1
      bin/client_msg/msg.ts
  3. 10 3
      gen_proto.sh
  4. 381 0
      src/server/msg/common.pb.go
  5. 1 1
      src/server/msg/msg.go

+ 2 - 0
bin/client_msg/common.proto

@@ -1,5 +1,7 @@
 syntax = "proto3";
 
+option go_package = "./msg";
+
 //登录
 message ResLogin {
   string openId = 1;

+ 1 - 1
bin/client_msg/msg.ts

@@ -2,5 +2,5 @@
 export enum MsgID {
     Hello = 0,
     ReqLogin = 1,
-    RespLogin = 2,
+    ResLogin = 2,
 }

+ 10 - 3
gen_proto.sh

@@ -7,9 +7,16 @@ export GOPATH=/home/zjh/teen_patti
 export PATH=$PATH:$GOPATH/bin:/usr/local/bin:$(go env GOPATH)/bin
 
 # 进入 proto 文件目录
-cd src/server/msg
+cd bin/client_msg
 
 # 生成 proto 文件
-protoc --go_out=. test.proto
+protoc --go_out=. common.proto
 
-echo "Proto files generated successfully!" 
+# 创建目标目录(如果不存在)
+mkdir -p ../../src/server/msg
+
+# 移动生成的文件到目标目录
+mv msg/common.pb.go ../../src/server/msg/
+rm -rf msg
+
+echo "Proto files generated and moved successfully!" 

+ 381 - 0
src/server/msg/common.pb.go

@@ -0,0 +1,381 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// versions:
+// 	protoc-gen-go v1.28.1
+// 	protoc        v3.20.0
+// source: common.proto
+
+package msg
+
+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 ResLogin struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	OpenId   string `protobuf:"bytes,1,opt,name=openId,proto3" json:"openId,omitempty"`
+	NikeName string `protobuf:"bytes,2,opt,name=nikeName,proto3" json:"nikeName,omitempty"`
+}
+
+func (x *ResLogin) Reset() {
+	*x = ResLogin{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_common_proto_msgTypes[0]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *ResLogin) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*ResLogin) ProtoMessage() {}
+
+func (x *ResLogin) ProtoReflect() protoreflect.Message {
+	mi := &file_common_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 ResLogin.ProtoReflect.Descriptor instead.
+func (*ResLogin) Descriptor() ([]byte, []int) {
+	return file_common_proto_rawDescGZIP(), []int{0}
+}
+
+func (x *ResLogin) GetOpenId() string {
+	if x != nil {
+		return x.OpenId
+	}
+	return ""
+}
+
+func (x *ResLogin) GetNikeName() string {
+	if x != nil {
+		return x.NikeName
+	}
+	return ""
+}
+
+// 登录 响应
+type ReqLogin struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	NikeName   string    `protobuf:"bytes,1,opt,name=nikeName,proto3" json:"nikeName,omitempty"`
+	UserId     string    `protobuf:"bytes,2,opt,name=userId,proto3" json:"userId,omitempty"`
+	GameStatus string    `protobuf:"bytes,3,opt,name=gameStatus,proto3" json:"gameStatus,omitempty"`
+	Error      *MsgError `protobuf:"bytes,4,opt,name=error,proto3" json:"error,omitempty"`
+}
+
+func (x *ReqLogin) Reset() {
+	*x = ReqLogin{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_common_proto_msgTypes[1]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *ReqLogin) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*ReqLogin) ProtoMessage() {}
+
+func (x *ReqLogin) ProtoReflect() protoreflect.Message {
+	mi := &file_common_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 ReqLogin.ProtoReflect.Descriptor instead.
+func (*ReqLogin) Descriptor() ([]byte, []int) {
+	return file_common_proto_rawDescGZIP(), []int{1}
+}
+
+func (x *ReqLogin) GetNikeName() string {
+	if x != nil {
+		return x.NikeName
+	}
+	return ""
+}
+
+func (x *ReqLogin) GetUserId() string {
+	if x != nil {
+		return x.UserId
+	}
+	return ""
+}
+
+func (x *ReqLogin) GetGameStatus() string {
+	if x != nil {
+		return x.GameStatus
+	}
+	return ""
+}
+
+func (x *ReqLogin) GetError() *MsgError {
+	if x != nil {
+		return x.Error
+	}
+	return nil
+}
+
+// error
+type MsgError struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	ErrorCode int32  `protobuf:"varint,1,opt,name=error_code,json=errorCode,proto3" json:"error_code,omitempty"`
+	ErrorMsg  string `protobuf:"bytes,2,opt,name=error_msg,json=errorMsg,proto3" json:"error_msg,omitempty"`
+}
+
+func (x *MsgError) Reset() {
+	*x = MsgError{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_common_proto_msgTypes[2]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *MsgError) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*MsgError) ProtoMessage() {}
+
+func (x *MsgError) ProtoReflect() protoreflect.Message {
+	mi := &file_common_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 MsgError.ProtoReflect.Descriptor instead.
+func (*MsgError) Descriptor() ([]byte, []int) {
+	return file_common_proto_rawDescGZIP(), []int{2}
+}
+
+func (x *MsgError) GetErrorCode() int32 {
+	if x != nil {
+		return x.ErrorCode
+	}
+	return 0
+}
+
+func (x *MsgError) GetErrorMsg() string {
+	if x != nil {
+		return x.ErrorMsg
+	}
+	return ""
+}
+
+type Hello struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+}
+
+func (x *Hello) Reset() {
+	*x = Hello{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_common_proto_msgTypes[3]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *Hello) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*Hello) ProtoMessage() {}
+
+func (x *Hello) ProtoReflect() protoreflect.Message {
+	mi := &file_common_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 Hello.ProtoReflect.Descriptor instead.
+func (*Hello) Descriptor() ([]byte, []int) {
+	return file_common_proto_rawDescGZIP(), []int{3}
+}
+
+func (x *Hello) GetName() string {
+	if x != nil {
+		return x.Name
+	}
+	return ""
+}
+
+var File_common_proto protoreflect.FileDescriptor
+
+var file_common_proto_rawDesc = []byte{
+	0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x3e,
+	0x0a, 0x08, 0x52, 0x65, 0x73, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x70,
+	0x65, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x70, 0x65, 0x6e,
+	0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x69, 0x6b, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02,
+	0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x69, 0x6b, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x7f,
+	0x0a, 0x08, 0x52, 0x65, 0x71, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x69,
+	0x6b, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x69,
+	0x6b, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64,
+	0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1e,
+	0x0a, 0x0a, 0x67, 0x61, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01,
+	0x28, 0x09, 0x52, 0x0a, 0x67, 0x61, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1f,
+	0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e,
+	0x4d, 0x73, 0x67, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22,
+	0x46, 0x0a, 0x08, 0x4d, 0x73, 0x67, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x65,
+	0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52,
+	0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x65, 0x72,
+	0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65,
+	0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x22, 0x1b, 0x0a, 0x05, 0x48, 0x65, 0x6c, 0x6c, 0x6f,
+	0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
+	0x6e, 0x61, 0x6d, 0x65, 0x42, 0x07, 0x5a, 0x05, 0x2e, 0x2f, 0x6d, 0x73, 0x67, 0x62, 0x06, 0x70,
+	0x72, 0x6f, 0x74, 0x6f, 0x33,
+}
+
+var (
+	file_common_proto_rawDescOnce sync.Once
+	file_common_proto_rawDescData = file_common_proto_rawDesc
+)
+
+func file_common_proto_rawDescGZIP() []byte {
+	file_common_proto_rawDescOnce.Do(func() {
+		file_common_proto_rawDescData = protoimpl.X.CompressGZIP(file_common_proto_rawDescData)
+	})
+	return file_common_proto_rawDescData
+}
+
+var file_common_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
+var file_common_proto_goTypes = []interface{}{
+	(*ResLogin)(nil), // 0: ResLogin
+	(*ReqLogin)(nil), // 1: ReqLogin
+	(*MsgError)(nil), // 2: MsgError
+	(*Hello)(nil),    // 3: Hello
+}
+var file_common_proto_depIdxs = []int32{
+	2, // 0: ReqLogin.error:type_name -> MsgError
+	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_common_proto_init() }
+func file_common_proto_init() {
+	if File_common_proto != nil {
+		return
+	}
+	if !protoimpl.UnsafeEnabled {
+		file_common_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*ResLogin); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_common_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*ReqLogin); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_common_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*MsgError); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_common_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*Hello); 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_common_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   4,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_common_proto_goTypes,
+		DependencyIndexes: file_common_proto_depIdxs,
+		MessageInfos:      file_common_proto_msgTypes,
+	}.Build()
+	File_common_proto = out.File
+	file_common_proto_rawDesc = nil
+	file_common_proto_goTypes = nil
+	file_common_proto_depIdxs = nil
+}

+ 1 - 1
src/server/msg/msg.go

@@ -22,7 +22,7 @@ var msgList []MsgInfo
 func init() {
 	Processor.Register(&Hello{})
 	Processor.Register(&ReqLogin{})
-	Processor.Register(&RespLogin{})
+	Processor.Register(&ResLogin{})
 	Processor.Range(func(id uint16, t reflect.Type) {
 		log.Debug("消息ID: %d, 消息类型: %s\n", id, t.Elem().Name())
 		msgList = append(msgList, MsgInfo{