娃娃机心跳包

This commit is contained in:
by 2024-09-11 15:59:09 +08:00
parent 0855fc58f4
commit b53c78cfb3
5 changed files with 140 additions and 69 deletions

View File

@ -71,6 +71,9 @@ func MSUpdateDollMachineStatusHandler(session *netlib.Session, packetId int, dat
}
func MSDollMachineHeartBeatHandler(session *netlib.Session, packetId int, data interface{}) error {
//fmt.Println("收到娃娃机服务心跳!!!")
//返回心跳
pack := &machine.SMDollMachineHeartBeat{}
session.Send(int(machine.DollMachinePacketID_Packet_SMDollMachineHeartBeat), pack)
return nil
}

View File

@ -288,51 +288,57 @@ func SMGameLinkSucceedHandler(session *netlib.Session, packetId int, data interf
return nil
}
/*// 获取进入视频房间token
func SMGetTokenHandler(session *netlib.Session, packetId int, data interface{}) error {
logger.Logger.Tracef("SMGetTokenHandler %v", data)
msg, ok := data.(*machine.SMGetToken)
if !ok {
/*
// 获取进入视频房间token
func SMGetTokenHandler(session *netlib.Session, packetId int, data interface{}) error {
logger.Logger.Tracef("SMGetTokenHandler %v", data)
msg, ok := data.(*machine.SMGetToken)
if !ok {
return nil
}
// 请将 appId 修改为你的 appIdappid 为数字,从即构控制台获取
// 举例1234567890
var appId uint32 = uint32(msg.GetAppId())
// 请修改为你的 serverSecretserverSecret 为字符串,从即构控制台获取
// 举例: "fa94dd0f974cf2e293728a526b028271"
serverSecret := msg.ServerSecret
// 请将 userId 修改为用户的 user_id
userId := msg.GetSnid()
// token 的有效时长,单位:秒
var effectiveTimeInSeconds int64 = 3600
// token业务认证扩展基础鉴权token此处填空字符串
var payload string = ""
//生成token
token, err := token04.GenerateToken04(appId, strconv.Itoa(int(userId)), serverSecret, effectiveTimeInSeconds, payload)
if err != nil {
logger.Logger.Error(err)
return err
}
logger.Logger.Trace(token)
info := &machine.MSSendToken{}
info.Snid = msg.Snid
info.Token = token
info.Appid = msg.AppId
info.StreamId = msg.StreamId
session.Send(int(machine.DollMachinePacketID_PACKET_MSSendToken), info)
fmt.Println("向游戏服务器发送娃娃机token%v", info)
return nil
}
// 请将 appId 修改为你的 appIdappid 为数字,从即构控制台获取
// 举例1234567890
var appId uint32 = uint32(msg.GetAppId())
// 请修改为你的 serverSecretserverSecret 为字符串,从即构控制台获取
// 举例: "fa94dd0f974cf2e293728a526b028271"
serverSecret := msg.ServerSecret
// 请将 userId 修改为用户的 user_id
userId := msg.GetSnid()
// token 的有效时长,单位:秒
var effectiveTimeInSeconds int64 = 3600
// token业务认证扩展基础鉴权token此处填空字符串
var payload string = ""
//生成token
token, err := token04.GenerateToken04(appId, strconv.Itoa(int(userId)), serverSecret, effectiveTimeInSeconds, payload)
if err != nil {
logger.Logger.Error(err)
return err
}
logger.Logger.Trace(token)
info := &machine.MSSendToken{}
info.Snid = msg.Snid
info.Token = token
info.Appid = msg.AppId
info.StreamId = msg.StreamId
session.Send(int(machine.DollMachinePacketID_PACKET_MSSendToken), info)
fmt.Println("向游戏服务器发送娃娃机token%v", info)
*/
func SMDollMachineHeartBeatHandler(session *netlib.Session, packetId int, data interface{}) error {
//fmt.Println("收到返回的心跳包")
return nil
}*/
}
func init() {
netlib.Register(int(machine.DollMachinePacketID_PACKET_SMDollMachinePerate), &machine.SMDollMachineoPerate{}, SMDollMachinePerateHandler)
netlib.Register(int(machine.DollMachinePacketID_PACKET_SMDollMachineGrab), &machine.SMDollMachineGrab{}, SMDollMachineGrabHandler)
//链接成功 返回消息
netlib.Register(int(machine.DollMachinePacketID_PACKET_SMGameLinkSucceed), &machine.SMGameLinkSucceed{}, SMGameLinkSucceedHandler)
//netlib.Register(int(machine.DollMachinePacketID_PACKET_SMGetToken), &machine.SMGetToken{}, SMGetTokenHandler)
netlib.Register(int(machine.DollMachinePacketID_Packet_SMDollMachineHeartBeat), &machine.SMDollMachineHeartBeat{}, SMDollMachineHeartBeatHandler)
}

View File

@ -34,6 +34,7 @@ const (
DollMachinePacketID_PACKET_SMGetToken DollMachinePacketID = 20006
DollMachinePacketID_PACKET_MSSendToken DollMachinePacketID = 20007
DollMachinePacketID_Packet_MSDollMachineHeartBeat DollMachinePacketID = 20008
DollMachinePacketID_Packet_SMDollMachineHeartBeat DollMachinePacketID = 20009
)
// Enum value maps for DollMachinePacketID.
@ -49,6 +50,7 @@ var (
20006: "PACKET_SMGetToken",
20007: "PACKET_MSSendToken",
20008: "Packet_MSDollMachineHeartBeat",
20009: "Packet_SMDollMachineHeartBeat",
}
DollMachinePacketID_value = map[string]int32{
"PACKET_SMDollMachineZero": 0,
@ -61,6 +63,7 @@ var (
"PACKET_SMGetToken": 20006,
"PACKET_MSSendToken": 20007,
"Packet_MSDollMachineHeartBeat": 20008,
"Packet_SMDollMachineHeartBeat": 20009,
}
)
@ -538,6 +541,44 @@ func (*MSDollMachineHeartBeat) Descriptor() ([]byte, []int) {
return file_machine_proto_rawDescGZIP(), []int{7}
}
type SMDollMachineHeartBeat struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *SMDollMachineHeartBeat) Reset() {
*x = SMDollMachineHeartBeat{}
if protoimpl.UnsafeEnabled {
mi := &file_machine_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SMDollMachineHeartBeat) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SMDollMachineHeartBeat) ProtoMessage() {}
func (x *SMDollMachineHeartBeat) ProtoReflect() protoreflect.Message {
mi := &file_machine_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 SMDollMachineHeartBeat.ProtoReflect.Descriptor instead.
func (*SMDollMachineHeartBeat) Descriptor() ([]byte, []int) {
return file_machine_proto_rawDescGZIP(), []int{8}
}
var File_machine_proto protoreflect.FileDescriptor
var file_machine_proto_rawDesc = []byte{
@ -576,32 +617,36 @@ var file_machine_proto_rawDesc = []byte{
0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x41, 0x64,
0x64, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x41,
0x64, 0x64, 0x72, 0x22, 0x18, 0x0a, 0x16, 0x4d, 0x53, 0x44, 0x6f, 0x6c, 0x6c, 0x4d, 0x61, 0x63,
0x68, 0x69, 0x6e, 0x65, 0x48, 0x65, 0x61, 0x72, 0x74, 0x42, 0x65, 0x61, 0x74, 0x2a, 0xde, 0x02,
0x0a, 0x13, 0x44, 0x6f, 0x6c, 0x6c, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x50, 0x61, 0x63,
0x6b, 0x65, 0x74, 0x49, 0x44, 0x12, 0x1c, 0x0a, 0x18, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f,
0x53, 0x4d, 0x44, 0x6f, 0x6c, 0x6c, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x5a, 0x65, 0x72,
0x6f, 0x10, 0x00, 0x12, 0x1e, 0x0a, 0x18, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x4d,
0x47, 0x61, 0x6d, 0x65, 0x4c, 0x69, 0x6e, 0x6b, 0x53, 0x75, 0x63, 0x63, 0x65, 0x65, 0x64, 0x10,
0xa0, 0x9c, 0x01, 0x12, 0x20, 0x0a, 0x1a, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x4d,
0x44, 0x6f, 0x6c, 0x6c, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x50, 0x65, 0x72, 0x61, 0x74,
0x65, 0x10, 0xa1, 0x9c, 0x01, 0x12, 0x1e, 0x0a, 0x18, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f,
0x53, 0x4d, 0x44, 0x6f, 0x6c, 0x6c, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x47, 0x72, 0x61,
0x62, 0x10, 0xa2, 0x9c, 0x01, 0x12, 0x1e, 0x0a, 0x18, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f,
0x4d, 0x53, 0x44, 0x6f, 0x6c, 0x6c, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x4c, 0x69, 0x73,
0x74, 0x10, 0xa3, 0x9c, 0x01, 0x12, 0x26, 0x0a, 0x20, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f,
0x4d, 0x53, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x44, 0x6f, 0x6c, 0x6c, 0x4d, 0x61, 0x63, 0x68,
0x69, 0x6e, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x10, 0xa4, 0x9c, 0x01, 0x12, 0x27, 0x0a,
0x21, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x4d, 0x53, 0x44, 0x6f, 0x6c, 0x6c, 0x4d, 0x61,
0x63, 0x68, 0x69, 0x6e, 0x65, 0x6f, 0x50, 0x65, 0x72, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x75,
0x6c, 0x74, 0x10, 0xa5, 0x9c, 0x01, 0x12, 0x17, 0x0a, 0x11, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54,
0x5f, 0x53, 0x4d, 0x47, 0x65, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x10, 0xa6, 0x9c, 0x01, 0x12,
0x18, 0x0a, 0x12, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x4d, 0x53, 0x53, 0x65, 0x6e, 0x64,
0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x10, 0xa7, 0x9c, 0x01, 0x12, 0x23, 0x0a, 0x1d, 0x50, 0x61, 0x63,
0x6b, 0x65, 0x74, 0x5f, 0x4d, 0x53, 0x44, 0x6f, 0x6c, 0x6c, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e,
0x65, 0x48, 0x65, 0x61, 0x72, 0x74, 0x42, 0x65, 0x61, 0x74, 0x10, 0xa8, 0x9c, 0x01, 0x42, 0x27,
0x5a, 0x25, 0x6d, 0x6f, 0x6e, 0x67, 0x6f, 0x2e, 0x67, 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x63, 0x6f,
0x6d, 0x2f, 0x67, 0x61, 0x6d, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f,
0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x68, 0x69, 0x6e, 0x65, 0x48, 0x65, 0x61, 0x72, 0x74, 0x42, 0x65, 0x61, 0x74, 0x22, 0x18, 0x0a,
0x16, 0x53, 0x4d, 0x44, 0x6f, 0x6c, 0x6c, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x48, 0x65,
0x61, 0x72, 0x74, 0x42, 0x65, 0x61, 0x74, 0x2a, 0x83, 0x03, 0x0a, 0x13, 0x44, 0x6f, 0x6c, 0x6c,
0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x49, 0x44, 0x12,
0x1c, 0x0a, 0x18, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x4d, 0x44, 0x6f, 0x6c, 0x6c,
0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x5a, 0x65, 0x72, 0x6f, 0x10, 0x00, 0x12, 0x1e, 0x0a,
0x18, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x4d, 0x47, 0x61, 0x6d, 0x65, 0x4c, 0x69,
0x6e, 0x6b, 0x53, 0x75, 0x63, 0x63, 0x65, 0x65, 0x64, 0x10, 0xa0, 0x9c, 0x01, 0x12, 0x20, 0x0a,
0x1a, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x4d, 0x44, 0x6f, 0x6c, 0x6c, 0x4d, 0x61,
0x63, 0x68, 0x69, 0x6e, 0x65, 0x50, 0x65, 0x72, 0x61, 0x74, 0x65, 0x10, 0xa1, 0x9c, 0x01, 0x12,
0x1e, 0x0a, 0x18, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x4d, 0x44, 0x6f, 0x6c, 0x6c,
0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x47, 0x72, 0x61, 0x62, 0x10, 0xa2, 0x9c, 0x01, 0x12,
0x1e, 0x0a, 0x18, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x4d, 0x53, 0x44, 0x6f, 0x6c, 0x6c,
0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x10, 0xa3, 0x9c, 0x01, 0x12,
0x26, 0x0a, 0x20, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x4d, 0x53, 0x55, 0x70, 0x64, 0x61,
0x74, 0x65, 0x44, 0x6f, 0x6c, 0x6c, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x53, 0x74, 0x61,
0x74, 0x75, 0x73, 0x10, 0xa4, 0x9c, 0x01, 0x12, 0x27, 0x0a, 0x21, 0x50, 0x41, 0x43, 0x4b, 0x45,
0x54, 0x5f, 0x4d, 0x53, 0x44, 0x6f, 0x6c, 0x6c, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x6f,
0x50, 0x65, 0x72, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x10, 0xa5, 0x9c, 0x01,
0x12, 0x17, 0x0a, 0x11, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x4d, 0x47, 0x65, 0x74,
0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x10, 0xa6, 0x9c, 0x01, 0x12, 0x18, 0x0a, 0x12, 0x50, 0x41, 0x43,
0x4b, 0x45, 0x54, 0x5f, 0x4d, 0x53, 0x53, 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x10,
0xa7, 0x9c, 0x01, 0x12, 0x23, 0x0a, 0x1d, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x5f, 0x4d, 0x53,
0x44, 0x6f, 0x6c, 0x6c, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x48, 0x65, 0x61, 0x72, 0x74,
0x42, 0x65, 0x61, 0x74, 0x10, 0xa8, 0x9c, 0x01, 0x12, 0x23, 0x0a, 0x1d, 0x50, 0x61, 0x63, 0x6b,
0x65, 0x74, 0x5f, 0x53, 0x4d, 0x44, 0x6f, 0x6c, 0x6c, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65,
0x48, 0x65, 0x61, 0x72, 0x74, 0x42, 0x65, 0x61, 0x74, 0x10, 0xa9, 0x9c, 0x01, 0x42, 0x27, 0x5a,
0x25, 0x6d, 0x6f, 0x6e, 0x67, 0x6f, 0x2e, 0x67, 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x63, 0x6f, 0x6d,
0x2f, 0x67, 0x61, 0x6d, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x6d,
0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -617,7 +662,7 @@ func file_machine_proto_rawDescGZIP() []byte {
}
var file_machine_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_machine_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
var file_machine_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
var file_machine_proto_goTypes = []interface{}{
(DollMachinePacketID)(0), // 0: machine.DollMachinePacketID
(*SMGameLinkSucceed)(nil), // 1: machine.SMGameLinkSucceed
@ -628,6 +673,7 @@ var file_machine_proto_goTypes = []interface{}{
(*DollMachine)(nil), // 6: machine.DollMachine
(*MSUpdateDollMachineStatus)(nil), // 7: machine.MSUpdateDollMachineStatus
(*MSDollMachineHeartBeat)(nil), // 8: machine.MSDollMachineHeartBeat
(*SMDollMachineHeartBeat)(nil), // 9: machine.SMDollMachineHeartBeat
}
var file_machine_proto_depIdxs = []int32{
6, // 0: machine.MSDollMachineList.data:type_name -> machine.DollMachine
@ -740,6 +786,18 @@ func file_machine_proto_init() {
return nil
}
}
file_machine_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SMDollMachineHeartBeat); 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{
@ -747,7 +805,7 @@ func file_machine_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_machine_proto_rawDesc,
NumEnums: 1,
NumMessages: 8,
NumMessages: 9,
NumExtensions: 0,
NumServices: 0,
},

View File

@ -16,6 +16,7 @@ enum DollMachinePacketID {
PACKET_SMGetToken = 20006;
PACKET_MSSendToken = 20007;
Packet_MSDollMachineHeartBeat = 20008;
Packet_SMDollMachineHeartBeat = 20009;
}
//
//PACKET_SMDollMachinePerate
@ -63,4 +64,7 @@ message MSUpdateDollMachineStatus{
//
message MSDollMachineHeartBeat{
}
}
message SMDollMachineHeartBeat{
}

View File

@ -910,7 +910,7 @@ type CustomParam struct {
RoomTypeId int32 `protobuf:"varint,1,opt,name=RoomTypeId,proto3" json:"RoomTypeId,omitempty"` // 房间类型id
RoomConfigId int32 `protobuf:"varint,2,opt,name=RoomConfigId,proto3" json:"RoomConfigId,omitempty"` // 房间配置id
CostType int32 `protobuf:"varint,3,opt,name=CostType,proto3" json:"CostType,omitempty"` // 房卡场付费方式 1AA 2
CostType int32 `protobuf:"varint,3,opt,name=CostType,proto3" json:"CostType,omitempty"` // 房卡场付费方式 1AA 2房主
Password string `protobuf:"bytes,4,opt,name=Password,proto3" json:"Password,omitempty"` // 房间密码
Voice int32 `protobuf:"varint,5,opt,name=Voice,proto3" json:"Voice,omitempty"` // 是否开启语音 1开启 2关闭
}