Gogs 4 hónapja
szülő
commit
dde9895e1f

+ 8 - 0
bin/client_msg/common.proto

@@ -185,4 +185,12 @@ message Hello {
 
 message ReqRoomTipsMessage {
   string msg = 1;
+}
+
+message ResHeartBeat {
+  string msg = 1;
+}
+
+message ReqHeartBeat {
+  string msg = 1;
 }

+ 2 - 0
bin/client_msg/msg.ts

@@ -21,4 +21,6 @@ export enum MsgID {
     ReqPlayerList = 18,
     ReqResult = 19,
     ReqRoomTipsMessage = 20,
+    ReqHeartBeat = 21,
+    ResHeartBeat = 22,
 }

+ 9 - 0
src/server/game/internal/handler.go

@@ -6,10 +6,12 @@ import (
 	"server/msg"
 
 	"github.com/name5566/leaf/gate"
+	"github.com/name5566/leaf/log"
 )
 
 func init() {
 	Handler(&msg.ResPlayerOptAction{}, handlePlayerOptAction)
+	Handler(&msg.ResHeartBeat{}, handleHeartBeat)
 }
 
 func Handler(m interface{}, h interface{}) {
@@ -28,3 +30,10 @@ func handlePlayerOptAction(args []interface{}) {
 		}
 	}
 }
+
+func handleHeartBeat(args []interface{}) {
+	m := args[0].(*msg.ResHeartBeat)
+	a := args[1].(gate.Agent)
+	log.Debug("handleHeartBeat: %s", m.Msg)
+	a.WriteMsg(&msg.ReqHeartBeat{Msg: "pong"})
+}

+ 1 - 0
src/server/game/teen/round.go

@@ -176,6 +176,7 @@ func sendResult(r *room.Room, sitPos int32) {
 
 // 发房间动态消息提示
 func sendRoomDynamicMsg(r *room.Room, room_msg string) {
+	log.Debug("sendRoomDynamicMsg: %s", room_msg)
 	for _, player := range r.Players {
 		if player.Agent != nil {
 			player.Agent.WriteMsg(&msg.ReqRoomTipsMessage{Msg: room_msg})

+ 1 - 0
src/server/gate/router.go

@@ -12,4 +12,5 @@ func init() {
 	msg.Processor.SetRouter(&msg.ResGameInfo{}, hall.ChanRPC)
 	msg.Processor.SetRouter(&msg.ResJoinRoom{}, hall.ChanRPC)
 	msg.Processor.SetRouter(&msg.ResPlayerOptAction{}, game.ChanRPC)
+	msg.Processor.SetRouter(&msg.ResHeartBeat{}, game.ChanRPC)
 }

+ 137 - 12
src/server/msg/common.pb.go

@@ -1762,6 +1762,100 @@ func (x *ReqRoomTipsMessage) GetMsg() string {
 	return ""
 }
 
+type ResHeartBeat struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"`
+}
+
+func (x *ResHeartBeat) Reset() {
+	*x = ResHeartBeat{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_common_proto_msgTypes[27]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *ResHeartBeat) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*ResHeartBeat) ProtoMessage() {}
+
+func (x *ResHeartBeat) ProtoReflect() protoreflect.Message {
+	mi := &file_common_proto_msgTypes[27]
+	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 ResHeartBeat.ProtoReflect.Descriptor instead.
+func (*ResHeartBeat) Descriptor() ([]byte, []int) {
+	return file_common_proto_rawDescGZIP(), []int{27}
+}
+
+func (x *ResHeartBeat) GetMsg() string {
+	if x != nil {
+		return x.Msg
+	}
+	return ""
+}
+
+type ReqHeartBeat struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"`
+}
+
+func (x *ReqHeartBeat) Reset() {
+	*x = ReqHeartBeat{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_common_proto_msgTypes[28]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *ReqHeartBeat) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*ReqHeartBeat) ProtoMessage() {}
+
+func (x *ReqHeartBeat) ProtoReflect() protoreflect.Message {
+	mi := &file_common_proto_msgTypes[28]
+	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 ReqHeartBeat.ProtoReflect.Descriptor instead.
+func (*ReqHeartBeat) Descriptor() ([]byte, []int) {
+	return file_common_proto_rawDescGZIP(), []int{28}
+}
+
+func (x *ReqHeartBeat) GetMsg() string {
+	if x != nil {
+		return x.Msg
+	}
+	return ""
+}
+
 var File_common_proto protoreflect.FileDescriptor
 
 var file_common_proto_rawDesc = []byte{
@@ -1938,16 +2032,21 @@ var file_common_proto_rawDesc = []byte{
 	0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22,
 	0x26, 0x0a, 0x12, 0x52, 0x65, 0x71, 0x52, 0x6f, 0x6f, 0x6d, 0x54, 0x69, 0x70, 0x73, 0x4d, 0x65,
 	0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x01, 0x20, 0x01,
-	0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x2a, 0x84, 0x01, 0x0a, 0x0d, 0x50, 0x6c, 0x61, 0x79,
-	0x65, 0x72, 0x4f, 0x70, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x4f, 0x50, 0x54,
-	0x5f, 0x4e, 0x4f, 0x4e, 0x45, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x4f, 0x50, 0x54, 0x5f, 0x53,
-	0x45, 0x45, 0x4e, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x4f, 0x50, 0x54, 0x5f, 0x50, 0x41, 0x43,
-	0x4b, 0x45, 0x44, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x4f, 0x50, 0x54, 0x5f, 0x43, 0x48, 0x41,
-	0x41, 0x4c, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x4f, 0x50, 0x54, 0x5f, 0x42, 0x49, 0x4e, 0x44,
-	0x10, 0x04, 0x12, 0x0e, 0x0a, 0x0a, 0x4f, 0x50, 0x54, 0x5f, 0x53, 0x45, 0x4c, 0x45, 0x43, 0x54,
-	0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x4f, 0x50, 0x54, 0x5f, 0x53, 0x48, 0x4f, 0x57, 0x10, 0x06,
-	0x12, 0x0c, 0x0a, 0x08, 0x4f, 0x50, 0x54, 0x5f, 0x41, 0x4e, 0x54, 0x45, 0x10, 0x07, 0x42, 0x07,
-	0x5a, 0x05, 0x2e, 0x2f, 0x6d, 0x73, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x22, 0x20, 0x0a, 0x0c, 0x52, 0x65, 0x73, 0x48, 0x65,
+	0x61, 0x72, 0x74, 0x42, 0x65, 0x61, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x01,
+	0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x22, 0x20, 0x0a, 0x0c, 0x52, 0x65, 0x71,
+	0x48, 0x65, 0x61, 0x72, 0x74, 0x42, 0x65, 0x61, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67,
+	0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x2a, 0x84, 0x01, 0x0a, 0x0d,
+	0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x4f, 0x70, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0c, 0x0a,
+	0x08, 0x4f, 0x50, 0x54, 0x5f, 0x4e, 0x4f, 0x4e, 0x45, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x4f,
+	0x50, 0x54, 0x5f, 0x53, 0x45, 0x45, 0x4e, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x4f, 0x50, 0x54,
+	0x5f, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x44, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x4f, 0x50, 0x54,
+	0x5f, 0x43, 0x48, 0x41, 0x41, 0x4c, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x4f, 0x50, 0x54, 0x5f,
+	0x42, 0x49, 0x4e, 0x44, 0x10, 0x04, 0x12, 0x0e, 0x0a, 0x0a, 0x4f, 0x50, 0x54, 0x5f, 0x53, 0x45,
+	0x4c, 0x45, 0x43, 0x54, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x4f, 0x50, 0x54, 0x5f, 0x53, 0x48,
+	0x4f, 0x57, 0x10, 0x06, 0x12, 0x0c, 0x0a, 0x08, 0x4f, 0x50, 0x54, 0x5f, 0x41, 0x4e, 0x54, 0x45,
+	0x10, 0x07, 0x42, 0x07, 0x5a, 0x05, 0x2e, 0x2f, 0x6d, 0x73, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f,
+	0x74, 0x6f, 0x33,
 }
 
 var (
@@ -1963,7 +2062,7 @@ func file_common_proto_rawDescGZIP() []byte {
 }
 
 var file_common_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
-var file_common_proto_msgTypes = make([]protoimpl.MessageInfo, 27)
+var file_common_proto_msgTypes = make([]protoimpl.MessageInfo, 29)
 var file_common_proto_goTypes = []interface{}{
 	(PlayerOptType)(0),         // 0: PlayerOptType
 	(*ResLogin)(nil),           // 1: ResLogin
@@ -1993,6 +2092,8 @@ var file_common_proto_goTypes = []interface{}{
 	(*MsgError)(nil),           // 25: MsgError
 	(*Hello)(nil),              // 26: Hello
 	(*ReqRoomTipsMessage)(nil), // 27: ReqRoomTipsMessage
+	(*ResHeartBeat)(nil),       // 28: ResHeartBeat
+	(*ReqHeartBeat)(nil),       // 29: ReqHeartBeat
 }
 var file_common_proto_depIdxs = []int32{
 	25, // 0: ReqLogin.error:type_name -> MsgError
@@ -2346,6 +2447,30 @@ func file_common_proto_init() {
 				return nil
 			}
 		}
+		file_common_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*ResHeartBeat); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_common_proto_msgTypes[28].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*ReqHeartBeat); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
 	}
 	file_common_proto_msgTypes[12].OneofWrappers = []interface{}{}
 	file_common_proto_msgTypes[18].OneofWrappers = []interface{}{}
@@ -2356,7 +2481,7 @@ func file_common_proto_init() {
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: file_common_proto_rawDesc,
 			NumEnums:      1,
-			NumMessages:   27,
+			NumMessages:   29,
 			NumExtensions: 0,
 			NumServices:   0,
 		},

+ 2 - 0
src/server/msg/msg.go

@@ -44,6 +44,8 @@ func init() {
 	Processor.Register(&ReqPlayerList{})
 	Processor.Register(&ReqResult{})
 	Processor.Register(&ReqRoomTipsMessage{})
+	Processor.Register(&ReqHeartBeat{})
+	Processor.Register(&ResHeartBeat{})
 	Processor.Range(func(id uint16, t reflect.Type) {
 		log.Debug("消息ID: %d, 消息类型: %s\n", id, t.Elem().Name())
 		msgList = append(msgList, MsgInfo{