This commit is contained in:
aozhiwei 2023-08-10 19:13:34 +08:00
parent 51b43e47cf
commit bce3a2fed2
5 changed files with 65 additions and 0 deletions

View File

@ -7,12 +7,14 @@ import (
"q5"
"f5"
"cs"
)
type App_ struct {
f5.App_
msgMutex sync.Mutex
msgList q5.ListHead
workList q5.ListHead
}
var App = new (App_)
@ -22,6 +24,7 @@ func (this *App_) Init() {
f5.App.SetPkgName("imserver")
this.App_.Init(this.Update)
this.msgList.Init(nil)
this.workList.Init(nil)
WSPListener.Init()
go this.goReportServerState();
}
@ -32,6 +35,24 @@ func (this *App_) UnInit() {
}
func (this *App_) Update() {
if this.workList.Empty() {
this.msgMutex.Lock()
defer this.msgMutex.Unlock()
if !this.msgList.Empty() {
this.msgList.ReplaceInit(&this.workList)
}
}
for !this.workList.Empty() {
next := this.workList.Next()
hdr, ok := next.GetData().(*MsgHdr)
if ok {
handlerId := cs.GetMsgHandlerId(hdr.msgId)
if handlerId == PLAYER_MGR_HANDLER_ID {
cs.ProcessNsgMsg(hdr.msgId, PlayerMgr)
}
}
next.Del()
}
}
func (this *App_) goReportServerState() {

View File

@ -0,0 +1,5 @@
package main
const (
PLAYER_MGR_HANDLER_ID = iota
)

View File

@ -3,3 +3,29 @@ package cs
func ParsePb(msgId int, data []byte) interface{} {
return nil
}
type MsgHandler interface {
CMPing(*CMPing)
CMLogin(*CMLogin)
CMReconnect(*CMReconnect)
}
type MsgHandlerImpl struct {
}
func (this *MsgHandlerImpl) CMPing(msg *CMPing) {
}
func (this *MsgHandlerImpl) CMLogin(msg *CMLogin) {
}
func (this *MsgHandlerImpl) CMReconnect(msg *CMReconnect) {
}
func GetMsgHandlerId(msgId int) (int) {
return 0
}
func ProcessNsgMsg(msgId int, msgHandler MsgHandler) {
}

View File

@ -2,6 +2,8 @@ compile:
@. /etc/profile
protoc --proto_path=proto --go_out=./mtb proto/mt.proto
protoc --proto_path=proto --go_out=./cs proto/cs_msgid.proto
protoc --proto_path=proto --go_out=./cs proto/cs_proto.proto
@export GOPROXY=https://goproxy.io
@go build -gcflags=all="-N -l" -o ../../bin/imserver/
@echo "compile done"

View File

@ -0,0 +1,11 @@
package main
import (
"cs"
)
type PlayerMgr_ struct {
cs.MsgHandlerImpl
}
var PlayerMgr = new (PlayerMgr_)