1
This commit is contained in:
parent
51b43e47cf
commit
bce3a2fed2
@ -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() {
|
||||
|
5
server/imserver/constant.go
Normal file
5
server/imserver/constant.go
Normal file
@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
const (
|
||||
PLAYER_MGR_HANDLER_ID = iota
|
||||
)
|
@ -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) {
|
||||
|
||||
}
|
||||
|
@ -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"
|
||||
|
11
server/imserver/playermgr.go
Normal file
11
server/imserver/playermgr.go
Normal file
@ -0,0 +1,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"cs"
|
||||
)
|
||||
|
||||
type PlayerMgr_ struct {
|
||||
cs.MsgHandlerImpl
|
||||
}
|
||||
|
||||
var PlayerMgr = new (PlayerMgr_)
|
Loading…
x
Reference in New Issue
Block a user