Merge branch 'develop' of git.pogorockgames.com:mango-games/server/game into develop
This commit is contained in:
commit
a647da01aa
|
|
@ -67,7 +67,7 @@ func processConnMessageQueue(queue *ConnMessageQueue) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 移动
|
// 移动 1-前 2-后 3-左 4-右 5-投币
|
||||||
func SMDollMachinePerateHandler(session *netlib.Session, packetId int, data interface{}) error {
|
func SMDollMachinePerateHandler(session *netlib.Session, packetId int, data interface{}) error {
|
||||||
fmt.Println("SMDollMachinePerateHandler %v", data)
|
fmt.Println("SMDollMachinePerateHandler %v", data)
|
||||||
msg, ok := data.(*machine.SMDollMachineoPerate)
|
msg, ok := data.(*machine.SMDollMachineoPerate)
|
||||||
|
|
@ -86,15 +86,6 @@ func SMDollMachinePerateHandler(session *netlib.Session, packetId int, data inte
|
||||||
|
|
||||||
switch msg.Perate {
|
switch msg.Perate {
|
||||||
case 1:
|
case 1:
|
||||||
//向前移动
|
|
||||||
f1 := []func(){
|
|
||||||
func() { machinedoll.Backward(conn) },
|
|
||||||
}
|
|
||||||
f2 := []func(){
|
|
||||||
func() { machinedoll.BackwardStop(conn) },
|
|
||||||
}
|
|
||||||
Process(conn, f1, f2)
|
|
||||||
case 2:
|
|
||||||
//向后移动
|
//向后移动
|
||||||
f1 := []func(){
|
f1 := []func(){
|
||||||
func() { machinedoll.Forward(conn) },
|
func() { machinedoll.Forward(conn) },
|
||||||
|
|
@ -103,16 +94,16 @@ func SMDollMachinePerateHandler(session *netlib.Session, packetId int, data inte
|
||||||
func() { machinedoll.ForwardStop(conn) },
|
func() { machinedoll.ForwardStop(conn) },
|
||||||
}
|
}
|
||||||
Process(conn, f1, f2)
|
Process(conn, f1, f2)
|
||||||
case 3:
|
case 2:
|
||||||
//向左移动
|
//向前移动
|
||||||
f1 := []func(){
|
f1 := []func(){
|
||||||
func() { machinedoll.Left(conn) },
|
func() { machinedoll.Backward(conn) },
|
||||||
}
|
}
|
||||||
f2 := []func(){
|
f2 := []func(){
|
||||||
func() { machinedoll.LeftStop(conn) },
|
func() { machinedoll.BackwardStop(conn) },
|
||||||
}
|
}
|
||||||
Process(conn, f1, f2)
|
Process(conn, f1, f2)
|
||||||
case 4:
|
case 3:
|
||||||
//向右移动
|
//向右移动
|
||||||
f1 := []func(){
|
f1 := []func(){
|
||||||
func() { machinedoll.Right(conn) },
|
func() { machinedoll.Right(conn) },
|
||||||
|
|
@ -121,6 +112,16 @@ func SMDollMachinePerateHandler(session *netlib.Session, packetId int, data inte
|
||||||
func() { machinedoll.RightStop(conn) },
|
func() { machinedoll.RightStop(conn) },
|
||||||
}
|
}
|
||||||
Process(conn, f1, f2)
|
Process(conn, f1, f2)
|
||||||
|
case 4:
|
||||||
|
//向左移动
|
||||||
|
f1 := []func(){
|
||||||
|
func() { machinedoll.Left(conn) },
|
||||||
|
}
|
||||||
|
f2 := []func(){
|
||||||
|
func() { machinedoll.LeftStop(conn) },
|
||||||
|
}
|
||||||
|
Process(conn, f1, f2)
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
//投币
|
//投币
|
||||||
conn := machinedoll.MachineMgr.CreateConn(int(msg.GetId()))
|
conn := machinedoll.MachineMgr.CreateConn(int(msg.GetId()))
|
||||||
|
|
|
||||||
|
|
@ -133,48 +133,6 @@ func (this *MachineManager) Update() {
|
||||||
pack := &machine.MSDollMachineHeartBeat{}
|
pack := &machine.MSDollMachineHeartBeat{}
|
||||||
pack.TimeStamp = time.Now().UnixMilli()
|
pack.TimeStamp = time.Now().UnixMilli()
|
||||||
SendToGameServer(int(machine.DollMachinePacketID_Packet_MSDollMachineHeartBeat), pack)
|
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() {
|
func (this *MachineManager) Shutdown() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue