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 msgList q5.ListHead
} }
func (this *WSPListener) Init() { func (this *WSPListener) init() {
this.ch = make(chan *f5.MsgHdr) this.ch = make(chan *f5.MsgHdr)
listener, err := net.Listen("tcp", "0.0.0.0:" + listener, err := net.Listen("tcp", "0.0.0.0:" +
q5.ToString(mt.Table.IMServer.GetById(0).GetListenPort())) 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() { func (this *WSPListener) accept() {

View File

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

View File

@ -7,10 +7,10 @@ import (
type HandlerMgr struct { 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__CMPing), PLAYER_MGR_HANDLER_ID)
cs.RegHandlerId(int(cs.CMMessageIdE__CMLogin), 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 ( import (
"cs" "cs"
"q5"
"f5" "f5"
"time" "mt"
) )
type PlayerMgr struct { type PlayerMgr struct {
cs.MsgHandlerImpl 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) { func (this *PlayerMgr) CMLogin(hdr *f5.MsgHdr, msg *cs.CMLogin) {
serverInfo := "192.168.100.39:1000" serverInfo := "192.168.100.39:1000"
rspMsg := &cs.SMLogin{} rspMsg := &cs.SMLogin{}
@ -17,24 +31,22 @@ func (this *PlayerMgr) CMLogin(hdr *f5.MsgHdr, msg *cs.CMLogin) {
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg) wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
} }
func (this *PlayerMgr) goReportServerState() { func (this *PlayerMgr) reportServerState() {
for { params := map[string]string {
/* "node_id": q5.ToString(f5.GetApp().GetNodeId()),
params := q5.NewMxoObject() "instance_id": q5.ToString(f5.GetApp().GetInstanceId()),
params.SetXValue("node_id", q5.NewXInt32(1)) "ip": "",
params.SetXValue("instance_id", q5.NewXInt32(1)) "port": q5.ToString(mt.Table.IMServer.GetById(0).GetListenPort()),
params.SetXValue("ip", q5.NewXString("192.168.100.39")) "online_num": q5.ToString(0),
params.SetXValue("port", q5.NewXInt32(8888)) "room_num": q5.ToString(0),
params.SetXValue("online_num", q5.NewXInt32(1)) "channel": q5.ToString(0),
params.SetXValue("room_num", q5.NewXInt32(1)) "alive_count": q5.ToString(0),
params.SetXValue("channel", q5.NewXInt32(0)) "servicing": q5.ToString(1),
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)
} }
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