Compare commits
2 Commits
4cfd64dbed
...
1961caad12
Author | SHA1 | Date |
---|---|---|
|
1961caad12 | |
|
96268bf86f |
|
@ -119,8 +119,8 @@ func SMDollMachinePerateHandler(session *netlib.Session, packetId int, data inte
|
||||||
Process(conn, f1, f2)
|
Process(conn, f1, f2)
|
||||||
case 5:
|
case 5:
|
||||||
//投币
|
//投币
|
||||||
fmt.Println("===========玩家投币===========")
|
fmt.Println("===========玩家投币===========", conn)
|
||||||
go DollMachineGrabResult(session, conn, msg.Snid, msg.GetId())
|
go DollMachineGrabResult(conn, msg.Snid, msg.GetId())
|
||||||
machinedoll.Coin(conn)
|
machinedoll.Coin(conn)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ func SMDollMachineGrabHandler(session *netlib.Session, packetId int, data interf
|
||||||
}
|
}
|
||||||
|
|
||||||
// 监听抓取结果返回
|
// 监听抓取结果返回
|
||||||
func DollMachineGrabResult(session *netlib.Session, conn *machinedoll.Conn, snid, id int32) {
|
func DollMachineGrabResult(conn *machinedoll.Conn, snid, id int32) {
|
||||||
num := int64(1)
|
num := int64(1)
|
||||||
for {
|
for {
|
||||||
// 读取数据
|
// 读取数据
|
||||||
|
|
|
@ -10,11 +10,9 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"mongo.games.com/goserver/core/basic"
|
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
"mongo.games.com/goserver/core/module"
|
"mongo.games.com/goserver/core/module"
|
||||||
"mongo.games.com/goserver/core/netlib"
|
"mongo.games.com/goserver/core/netlib"
|
||||||
"mongo.games.com/goserver/core/task"
|
|
||||||
"mongo.games.com/goserver/srvlib"
|
"mongo.games.com/goserver/srvlib"
|
||||||
|
|
||||||
"mongo.games.com/game/protocol/machine"
|
"mongo.games.com/game/protocol/machine"
|
||||||
|
@ -90,48 +88,48 @@ func (this *MachineManager) Init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *MachineManager) Update() {
|
func (this *MachineManager) Update() {
|
||||||
var delConn []*Conn
|
/* 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()
|
|
||||||
logger.Logger.Tracef("断开连接:%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{} {
|
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||||
for id, addr := range this.DelConnMap {
|
for _, v := range this.ConnMap {
|
||||||
conn, err := net.DialTimeout("tcp", addr, 5*time.Second)
|
_, err := v.Write([]byte("heartbeat"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
delConn = append(delConn, v)
|
||||||
|
v.Close()
|
||||||
|
fmt.Println("断开连接:%v", v.Addr)
|
||||||
|
this.UpdateToGameServer(v, 0)
|
||||||
}
|
}
|
||||||
logger.Logger.Tracef("娃娃机重连成功!addr = %v", addr)
|
|
||||||
delIds = append(delIds, &Conn{
|
|
||||||
Id: id,
|
|
||||||
Conn: conn,
|
|
||||||
Addr: addr,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) {
|
}), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) {
|
||||||
for _, v := range delIds {
|
for _, v := range delConn {
|
||||||
this.ConnMap[v.Id] = v
|
delete(this.ConnMap, v.Id)
|
||||||
delete(this.DelConnMap, v.Id)
|
this.DelConnMap[v.Id] = v.Addr
|
||||||
this.UpdateToGameServer(v, 1)
|
|
||||||
}
|
}
|
||||||
})).StartByFixExecutor(this.ModuleName())
|
|
||||||
})).StartByFixExecutor(this.ModuleName())
|
// 重连
|
||||||
|
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() {
|
||||||
|
@ -204,8 +202,6 @@ func listenKeyboardEvents(conn net.Conn) {
|
||||||
case "j":
|
case "j":
|
||||||
Grab(conn)
|
Grab(conn)
|
||||||
case "J":
|
case "J":
|
||||||
SetPower(conn)
|
|
||||||
time.Sleep(200 * time.Millisecond)
|
|
||||||
Grab(conn)
|
Grab(conn)
|
||||||
|
|
||||||
case "k":
|
case "k":
|
||||||
|
|
Loading…
Reference in New Issue