From 6a9c6a988b1069de06f7ee8d210a5f356f9715ca Mon Sep 17 00:00:00 2001 From: kxdd Date: Mon, 2 Sep 2024 16:23:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A8=83=E5=A8=83=E6=9C=BA=E8=8E=B7=E5=8F=96to?= =?UTF-8?q?ken=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gamesrv/clawdoll/action_clawdoll.go | 3 +- gamesrv/clawdoll/scenepolicy_clawdoll.go | 36 +++++++++++ machine/action/action_server.go | 3 + protocol/machine/machine.pb.go | 78 +++++++++++++++--------- protocol/machine/machine.proto | 2 + 5 files changed, 91 insertions(+), 31 deletions(-) diff --git a/gamesrv/clawdoll/action_clawdoll.go b/gamesrv/clawdoll/action_clawdoll.go index fa25bf6..7036746 100644 --- a/gamesrv/clawdoll/action_clawdoll.go +++ b/gamesrv/clawdoll/action_clawdoll.go @@ -92,6 +92,7 @@ func (h *CSGetTokenHandler) Process(s *netlib.Session, packetid int, data interf } pack := &machine.SMGetToken{} pack.Snid = p.SnId + pack.Sid = p.GetSid() scene := p.GetScene() if scene == nil { @@ -122,7 +123,7 @@ func MSSendTokenHandler(session *netlib.Session, packetId int, data interface{}) if msg, ok := data.(*machine.MSSendToken); ok { //给客户端返回token token := msg.Token - p := base.PlayerMgrSington.GetPlayer(int64(msg.Snid)) + p := base.PlayerMgrSington.GetPlayer(int64(msg.GetSid())) if p == nil { logger.Logger.Warn("MSSendTokenHandler p == nil") return nil diff --git a/gamesrv/clawdoll/scenepolicy_clawdoll.go b/gamesrv/clawdoll/scenepolicy_clawdoll.go index 4128a09..6246929 100644 --- a/gamesrv/clawdoll/scenepolicy_clawdoll.go +++ b/gamesrv/clawdoll/scenepolicy_clawdoll.go @@ -3,6 +3,7 @@ package clawdoll import ( "mongo.games.com/game/gamesrv/action" "mongo.games.com/game/protocol/clawdoll" + "mongo.games.com/game/protocol/machine" "time" "mongo.games.com/goserver/core" @@ -117,6 +118,8 @@ func (this *PolicyClawdoll) OnPlayerEnter(s *base.Scene, p *base.Player) { // 玩家数据发送 sceneEx.OnPlayerEnter(p, 0) + + this.SendGetVideoToken(s, p, sceneEx) s.FirePlayerEvent(p, base.PlayerEventEnter, nil) } } @@ -173,6 +176,8 @@ func (this *PolicyClawdoll) OnPlayerRehold(s *base.Scene, p *base.Player) { this.SendRoomInfo(s, p, sceneEx) ClawdollBroadcastRoomWaitPlayers(s) ClawdollBroadcastPlayingInfo(s) + + this.SendGetVideoToken(s, p, sceneEx) s.FirePlayerEvent(p, base.PlayerEventRehold, nil) } } @@ -193,6 +198,7 @@ func (this *PolicyClawdoll) OnPlayerReturn(s *base.Scene, p *base.Player) { ClawdollBroadcastRoomWaitPlayers(s) ClawdollBroadcastPlayingInfo(s) + this.SendGetVideoToken(s, p, sceneEx) s.FirePlayerEvent(p, base.PlayerEventReturn, nil) } } @@ -256,11 +262,41 @@ func (this *PolicyClawdoll) CanChangeCoinScene(s *base.Scene, p *base.Player) bo } func (this *PolicyClawdoll) SendRoomInfo(s *base.Scene, p *base.Player, sceneEx *SceneEx) { + if s == nil || p == nil || sceneEx == nil { + return + } + pack := sceneEx.ClawdollCreateRoomInfoPacket(s, p) p.SendToClient(int(clawdoll.CLAWDOLLPacketID_PACKET_SC_ROOMINFO), pack) } +func (this *PolicyClawdoll) SendGetVideoToken(s *base.Scene, p *base.Player, sceneEx *SceneEx) { + //转发到娃娃机主机 + if s == nil || p == nil || sceneEx == nil { + return + } + logger.Logger.Tracef("ClawdollGetVideoToken") + if p == nil { + logger.Logger.Warn("ClawdollGetVideoToken p == nil") + return + } + pack := &machine.SMGetToken{} + pack.Snid = p.SnId + pack.Sid = p.GetSid() + + machineId := s.DbGameFree.GetId() % 6080000 + appId, serverSecret := sceneEx.GetMachineServerSecret(machineId, p.Platform) + logger.Logger.Tracef("获取娃娃机 appId = %v, serverSecret = %v", appId, serverSecret) + if serverSecret == "" || appId == 0 { + return + } + + pack.ServerSecret = serverSecret + pack.AppId = appId + sceneEx.SendToMachine(int(machine.DollMachinePacketID_PACKET_SMGetToken), pack) +} + // 广播房间状态 func ClawdollBroadcastRoomState(s *base.Scene, params ...float32) { pack := &clawdoll.SCCLAWDOLLRoomState{ diff --git a/machine/action/action_server.go b/machine/action/action_server.go index 7f7acd6..561f364 100644 --- a/machine/action/action_server.go +++ b/machine/action/action_server.go @@ -300,6 +300,9 @@ func SMGetTokenHandler(session *netlib.Session, packetId int, data interface{}) info := &machine.MSSendToken{} info.Snid = msg.Snid info.Token = token + info.Sid = msg.GetSid() + info.Appid = msg.AppId + session.Send(int(machine.DollMachinePacketID_PACKET_MSSendToken), info) logger.Logger.Tracef("向游戏服务器发送娃娃机token:%v", info) return nil diff --git a/protocol/machine/machine.pb.go b/protocol/machine/machine.pb.go index 464b384..39a1133 100644 --- a/protocol/machine/machine.pb.go +++ b/protocol/machine/machine.pb.go @@ -505,6 +505,7 @@ type SMGetToken struct { Snid int32 `protobuf:"varint,1,opt,name=Snid,proto3" json:"Snid,omitempty"` AppId int64 `protobuf:"varint,2,opt,name=AppId,proto3" json:"AppId,omitempty"` ServerSecret string `protobuf:"bytes,3,opt,name=ServerSecret,proto3" json:"ServerSecret,omitempty"` + Sid int64 `protobuf:"varint,4,opt,name=Sid,proto3" json:"Sid,omitempty"` } func (x *SMGetToken) Reset() { @@ -560,6 +561,13 @@ func (x *SMGetToken) GetServerSecret() string { return "" } +func (x *SMGetToken) GetSid() int64 { + if x != nil { + return x.Sid + } + return 0 +} + //返回token type MSSendToken struct { state protoimpl.MessageState @@ -569,6 +577,7 @@ type MSSendToken struct { Snid int32 `protobuf:"varint,1,opt,name=Snid,proto3" json:"Snid,omitempty"` Appid int64 `protobuf:"varint,2,opt,name=Appid,proto3" json:"Appid,omitempty"` Token string `protobuf:"bytes,3,opt,name=Token,proto3" json:"Token,omitempty"` + Sid int64 `protobuf:"varint,4,opt,name=Sid,proto3" json:"Sid,omitempty"` } func (x *MSSendToken) Reset() { @@ -624,6 +633,13 @@ func (x *MSSendToken) GetToken() string { return "" } +func (x *MSSendToken) GetSid() int64 { + if x != nil { + return x.Sid + } + return 0 +} + var File_machine_proto protoreflect.FileDescriptor var file_machine_proto_rawDesc = []byte{ @@ -661,40 +677,42 @@ var file_machine_proto_rawDesc = []byte{ 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x53, 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, 0x5a, 0x0a, 0x0a, 0x53, 0x4d, 0x47, 0x65, 0x74, 0x54, 0x6f, 0x6b, 0x65, + 0x64, 0x64, 0x72, 0x22, 0x6c, 0x0a, 0x0a, 0x53, 0x4d, 0x47, 0x65, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x53, 0x6e, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x53, 0x6e, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x41, 0x70, 0x70, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x41, 0x70, 0x70, 0x49, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x22, - 0x4d, 0x0a, 0x0b, 0x4d, 0x53, 0x53, 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x12, - 0x0a, 0x04, 0x53, 0x6e, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x53, 0x6e, - 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x41, 0x70, 0x70, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x05, 0x41, 0x70, 0x70, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x6f, 0x6b, 0x65, - 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x2a, 0xb9, - 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, 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, + 0x09, 0x52, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x12, + 0x10, 0x0a, 0x03, 0x53, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x53, 0x69, + 0x64, 0x22, 0x5f, 0x0a, 0x0b, 0x4d, 0x53, 0x53, 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x6b, 0x65, 0x6e, + 0x12, 0x12, 0x0a, 0x04, 0x53, 0x6e, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, + 0x53, 0x6e, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x41, 0x70, 0x70, 0x69, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x05, 0x41, 0x70, 0x70, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x6f, + 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x54, 0x6f, 0x6b, 0x65, 0x6e, + 0x12, 0x10, 0x0a, 0x03, 0x53, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x53, + 0x69, 0x64, 0x2a, 0xb9, 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, 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 ( diff --git a/protocol/machine/machine.proto b/protocol/machine/machine.proto index 472cb4b..5cbb18e 100644 --- a/protocol/machine/machine.proto +++ b/protocol/machine/machine.proto @@ -64,10 +64,12 @@ message SMGetToken{ int32 Snid = 1; int64 AppId = 2; string ServerSecret = 3; + int64 Sid = 4; } //返回token message MSSendToken{ int32 Snid = 1; int64 Appid = 2; string Token = 3; + int64 Sid = 4; } \ No newline at end of file