This commit is contained in:
azw 2023-08-13 14:27:47 +08:00
parent 9898df3536
commit 4f277ce1cb
5 changed files with 43 additions and 29 deletions

View File

@ -18,7 +18,7 @@ type WSPListener struct {
msgList q5.ListHead
}
func (this *WSPListener) Init() {
func (this *WSPListener) init() {
this.ch = make(chan *f5.MsgHdr)
listener, err := net.Listen("tcp", "0.0.0.0:" +
q5.ToString(mt.Table.IMServer.GetById(0).GetListenPort()))
@ -31,7 +31,7 @@ func (this *WSPListener) Init() {
}
}
func (this *WSPListener) UnInit() {
func (this *WSPListener) unInit() {
}
func (this *WSPListener) accept() {

View File

@ -19,13 +19,15 @@ func (this *App) Init() {
this.netMsgQueue.Init()
f5.LoadMetaTable(mt.Table)
handlerMgr.Init()
wspListener.Init()
handlerMgr.init()
playerMgr.init()
wspListener.init()
}
func (this *App) UnInit() {
handlerMgr.UnInit()
wspListener.UnInit()
playerMgr.unInit()
handlerMgr.unInit()
wspListener.unInit()
}
func (this *App) Update() {

View File

@ -7,10 +7,10 @@ import (
type HandlerMgr struct {
}
func (this *HandlerMgr) Init() {
func (this *HandlerMgr) init() {
cs.RegHandlerId(int(cs.CMMessageIdE__CMPing), PLAYER_MGR_HANDLER_ID)
cs.RegHandlerId(int(cs.CMMessageIdE__CMLogin), PLAYER_MGR_HANDLER_ID)
}
func (this *HandlerMgr) UnInit() {
func (this *HandlerMgr) unInit() {
}

View File

@ -2,14 +2,28 @@ package main
import (
"cs"
"q5"
"f5"
"time"
"mt"
)
type PlayerMgr struct {
cs.MsgHandlerImpl
}
func (this *PlayerMgr) init() {
f5.GetTimer().SetInterval(
1000,
func (e int32, args *q5.Args) {
if e == q5.TIMER_EXEC_EVENT {
this.reportServerState()
}
})
}
func (this *PlayerMgr) unInit() {
}
func (this *PlayerMgr) CMLogin(hdr *f5.MsgHdr, msg *cs.CMLogin) {
serverInfo := "192.168.100.39:1000"
rspMsg := &cs.SMLogin{}
@ -17,24 +31,22 @@ func (this *PlayerMgr) CMLogin(hdr *f5.MsgHdr, msg *cs.CMLogin) {
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
}
func (this *PlayerMgr) goReportServerState() {
for {
/*
params := q5.NewMxoObject()
params.SetXValue("node_id", q5.NewXInt32(1))
params.SetXValue("instance_id", q5.NewXInt32(1))
params.SetXValue("ip", q5.NewXString("192.168.100.39"))
params.SetXValue("port", q5.NewXInt32(8888))
params.SetXValue("online_num", q5.NewXInt32(1))
params.SetXValue("room_num", q5.NewXInt32(1))
params.SetXValue("channel", q5.NewXInt32(0))
params.SetXValue("alive_count", q5.NewXInt32(1))
params.SetXValue("servicing", q5.NewXInt32(1))
_, err := q5.HttpGet(
"http://192.168.100.45:7821/webapp/index.php?c=GS&a=report&",
params.AsXObject())
fmt.Println(err);
*/
time.Sleep(time.Duration(1) * time.Second)
func (this *PlayerMgr) reportServerState() {
params := map[string]string {
"node_id": q5.ToString(f5.GetApp().GetNodeId()),
"instance_id": q5.ToString(f5.GetApp().GetInstanceId()),
"ip": "",
"port": q5.ToString(mt.Table.IMServer.GetById(0).GetListenPort()),
"online_num": q5.ToString(0),
"room_num": q5.ToString(0),
"channel": q5.ToString(0),
"alive_count": q5.ToString(0),
"servicing": q5.ToString(1),
}
f5.GetHttpCliMgr().SendQuickChannelJsLikeRequest(
"http://192.168.100.45:7821/webapp/index.php?c=GS&a=report&",
params,
func (rsp f5.HttpCliResponse) {
f5.GetSysLog().Info(rsp.GetRawData())
})
}

2
third_party/f5 vendored

@ -1 +1 @@
Subproject commit 1db5053277eab004bd09af83ddbe1569e9492b53
Subproject commit af8b11817827dfcb4deb7fe4f8c1b5bc4edb07d0