From a314c42d6ce496dbe66720d236e465cebaa5a3a0 Mon Sep 17 00:00:00 2001 From: by <123456@qq.com> Date: Sat, 14 Sep 2024 15:53:03 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=A8=83=E5=A8=83=E6=9C=BA=E8=B0=83?= =?UTF-8?q?=E8=BD=AC=E6=96=B9=E5=90=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- machine/action/action_server.go | 36 +++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/machine/action/action_server.go b/machine/action/action_server.go index 024cb99..c5120c1 100644 --- a/machine/action/action_server.go +++ b/machine/action/action_server.go @@ -67,7 +67,7 @@ func processConnMessageQueue(queue *ConnMessageQueue) { } } -// 移动 +// 移动 1-前 2-后 3-左 4-右 5-投币 func SMDollMachinePerateHandler(session *netlib.Session, packetId int, data interface{}) error { fmt.Println("SMDollMachinePerateHandler %v", data) msg, ok := data.(*machine.SMDollMachineoPerate) @@ -86,15 +86,6 @@ func SMDollMachinePerateHandler(session *netlib.Session, packetId int, data inte switch msg.Perate { case 1: - //向前移动 - f1 := []func(){ - func() { machinedoll.Backward(conn) }, - } - f2 := []func(){ - func() { machinedoll.BackwardStop(conn) }, - } - Process(conn, f1, f2) - case 2: //向后移动 f1 := []func(){ func() { machinedoll.Forward(conn) }, @@ -103,16 +94,16 @@ func SMDollMachinePerateHandler(session *netlib.Session, packetId int, data inte func() { machinedoll.ForwardStop(conn) }, } Process(conn, f1, f2) - case 3: - //向左移动 + case 2: + //向前移动 f1 := []func(){ - func() { machinedoll.Left(conn) }, + func() { machinedoll.Backward(conn) }, } f2 := []func(){ - func() { machinedoll.LeftStop(conn) }, + func() { machinedoll.BackwardStop(conn) }, } Process(conn, f1, f2) - case 4: + case 3: //向右移动 f1 := []func(){ func() { machinedoll.Right(conn) }, @@ -121,6 +112,16 @@ func SMDollMachinePerateHandler(session *netlib.Session, packetId int, data inte func() { machinedoll.RightStop(conn) }, } Process(conn, f1, f2) + case 4: + //向左移动 + f1 := []func(){ + func() { machinedoll.Left(conn) }, + } + f2 := []func(){ + func() { machinedoll.LeftStop(conn) }, + } + Process(conn, f1, f2) + case 5: //投币 conn := machinedoll.MachineMgr.CreateConn(int(msg.GetId())) @@ -284,6 +285,7 @@ func SMGameLinkSucceedHandler(session *netlib.Session, packetId int, data interf msg.Data = append(msg.Data, info) } session.Send(int(machine.DollMachinePacketID_PACKET_MSDollMachineList), msg) + machinedoll.MachineMgr.BeatStatus = true fmt.Println("向游戏服务器发送娃娃机连接信息:%v", msg) return nil } @@ -333,6 +335,10 @@ func SMGameLinkSucceedHandler(session *netlib.Session, packetId int, data interf */ func SMDollMachineHeartBeatHandler(session *netlib.Session, packetId int, data interface{}) error { //fmt.Println("收到返回的心跳包") + machinedoll.MachineMgr.BeatCount-- + if machinedoll.MachineMgr.BeatCount < 0 { + machinedoll.MachineMgr.BeatCount = 0 + } return nil } func init() { From 72edbbdd4b5866ea1b0c496ae0925f1998dddb8f Mon Sep 17 00:00:00 2001 From: by <123456@qq.com> Date: Sat, 14 Sep 2024 15:54:38 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=A8=83=E5=A8=83=E6=9C=BA=E8=B0=83?= =?UTF-8?q?=E8=BD=AC=E6=96=B9=E5=90=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- machine/action/action_server.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/machine/action/action_server.go b/machine/action/action_server.go index c5120c1..92d3990 100644 --- a/machine/action/action_server.go +++ b/machine/action/action_server.go @@ -285,7 +285,6 @@ func SMGameLinkSucceedHandler(session *netlib.Session, packetId int, data interf msg.Data = append(msg.Data, info) } session.Send(int(machine.DollMachinePacketID_PACKET_MSDollMachineList), msg) - machinedoll.MachineMgr.BeatStatus = true fmt.Println("向游戏服务器发送娃娃机连接信息:%v", msg) return nil } @@ -335,10 +334,6 @@ func SMGameLinkSucceedHandler(session *netlib.Session, packetId int, data interf */ func SMDollMachineHeartBeatHandler(session *netlib.Session, packetId int, data interface{}) error { //fmt.Println("收到返回的心跳包") - machinedoll.MachineMgr.BeatCount-- - if machinedoll.MachineMgr.BeatCount < 0 { - machinedoll.MachineMgr.BeatCount = 0 - } return nil } func init() { From 7668ddcd93e3823819631cb70103aa7b853a6e88 Mon Sep 17 00:00:00 2001 From: by <123456@qq.com> Date: Sat, 14 Sep 2024 15:55:37 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=A8=83=E5=A8=83=E6=9C=BA=E8=B0=83?= =?UTF-8?q?=E8=BD=AC=E6=96=B9=E5=90=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- machine/machinedoll/machinemgr.go | 42 ------------------------------- 1 file changed, 42 deletions(-) diff --git a/machine/machinedoll/machinemgr.go b/machine/machinedoll/machinemgr.go index b4cbf18..61f7c51 100644 --- a/machine/machinedoll/machinemgr.go +++ b/machine/machinedoll/machinemgr.go @@ -133,48 +133,6 @@ func (this *MachineManager) Update() { pack := &machine.MSDollMachineHeartBeat{} pack.TimeStamp = time.Now().UnixMilli() SendToGameServer(int(machine.DollMachinePacketID_Packet_MSDollMachineHeartBeat), pack) - /* var delConn []*Conn - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - for _, v := range this.ConnMap { - _, err := v.Write([]byte("heartbeat")) - if err != nil { - delConn = append(delConn, v) - v.Close() - fmt.Println("断开连接:%v", v.Addr) - this.UpdateToGameServer(v, 0) - } - } - return nil - }), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) { - for _, v := range delConn { - delete(this.ConnMap, v.Id) - this.DelConnMap[v.Id] = v.Addr - } - - // 重连 - var delIds []*Conn - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - for id, addr := range this.DelConnMap { - conn, err := net.DialTimeout("tcp", addr, 5*time.Second) - if err != nil { - continue - } - fmt.Println("娃娃机重连成功!addr = %v", addr) - delIds = append(delIds, &Conn{ - Id: id, - Conn: conn, - Addr: addr, - }) - } - return nil - }), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) { - for _, v := range delIds { - this.ConnMap[v.Id] = v - delete(this.DelConnMap, v.Id) - this.UpdateToGameServer(v, 1) - } - })).StartByFixExecutor(this.ModuleName()) - })).StartByFixExecutor(this.ModuleName())*/ } func (this *MachineManager) Shutdown() {