This commit is contained in:
aozhiwei 2023-09-07 14:13:20 +08:00
parent 35740b3891
commit 6405a233fd
5 changed files with 19 additions and 19 deletions

View File

@ -6,7 +6,7 @@ import (
"mt" "mt"
"cs" "cs"
"ss" "ss"
. "main/common" "main/constant"
. "main/global" . "main/global"
) )
@ -46,7 +46,7 @@ func (this *app) Update() {
handler := ss.GetNetMsgHandler(hdr.MsgId) handler := ss.GetNetMsgHandler(hdr.MsgId)
if handler != nil { if handler != nil {
switch handler.HandlerId { switch handler.HandlerId {
case WSP_LISTENER_HANDLER_ID: case constant.WSP_LISTENER_HANDLER_ID:
GetWspListener().ProcessSSMMsg(handler, hdr) GetWspListener().ProcessSSMMsg(handler, hdr)
} }
} }
@ -54,8 +54,8 @@ func (this *app) Update() {
handler := cs.GetNetMsgHandler(hdr.MsgId) handler := cs.GetNetMsgHandler(hdr.MsgId)
if handler != nil { if handler != nil {
switch handler.HandlerId { switch handler.HandlerId {
case PLAYER_MGR_HANDLER_ID: case constant.PLAYER_MGR_HANDLER_ID:
case PLAYER_HANDLER_ID: case constant.PLAYER_HANDLER_ID:
GetPlayerMgr().ProcessCMMsg(handler, hdr) GetPlayerMgr().ProcessCMMsg(handler, hdr)
} }
} }
@ -72,7 +72,7 @@ func (this *app) addNetMsg(hdr *f5.MsgHdr) {
func (this *app) registerDataSources() { func (this *app) registerDataSources() {
f5.GetJsStyleDb().RegisterDataSource( f5.GetJsStyleDb().RegisterDataSource(
GAME_DB, constant.GAME_DB,
mt.Table.GameDb.GetById(0).GetHost(), mt.Table.GameDb.GetById(0).GetHost(),
mt.Table.GameDb.GetById(0).GetPort(), mt.Table.GameDb.GetById(0).GetPort(),
mt.Table.GameDb.GetById(0).GetUser(), mt.Table.GameDb.GetById(0).GetUser(),
@ -80,7 +80,7 @@ func (this *app) registerDataSources() {
mt.Table.GameDb.GetById(0).GetDatabase(), mt.Table.GameDb.GetById(0).GetDatabase(),
30) 30)
f5.GetJsStyleDb().RegisterDataSource( f5.GetJsStyleDb().RegisterDataSource(
FRIEND_DB, constant.FRIEND_DB,
mt.Table.FriendDb.GetById(0).GetHost(), mt.Table.FriendDb.GetById(0).GetHost(),
mt.Table.FriendDb.GetById(0).GetPort(), mt.Table.FriendDb.GetById(0).GetPort(),
mt.Table.FriendDb.GetById(0).GetUser(), mt.Table.FriendDb.GetById(0).GetUser(),

View File

@ -1,4 +1,4 @@
package common package constant
const ( const (
PLAYER_MGR_HANDLER_ID = 1 PLAYER_MGR_HANDLER_ID = 1

View File

@ -4,18 +4,18 @@ import (
"cs" "cs"
"ss" "ss"
. "main/common" "main/constant"
) )
type HandlerMgr struct { type HandlerMgr struct {
} }
func (this *HandlerMgr) Init() { func (this *HandlerMgr) Init() {
ss.RegHandlerId(int(ss.SSMessageIdE__SS_Ping), WSP_LISTENER_HANDLER_ID) ss.RegHandlerId(int(ss.SSMessageIdE__SS_Ping), constant.WSP_LISTENER_HANDLER_ID)
ss.RegHandlerId(int(ss.SSMessageIdE__SS_WSP_SocketDisconnect), WSP_LISTENER_HANDLER_ID) ss.RegHandlerId(int(ss.SSMessageIdE__SS_WSP_SocketDisconnect), constant.WSP_LISTENER_HANDLER_ID)
cs.RegHandlerId(int(cs.CMMessageIdE__CMPing), PLAYER_MGR_HANDLER_ID) cs.RegHandlerId(int(cs.CMMessageIdE__CMPing), constant.PLAYER_MGR_HANDLER_ID)
cs.RegHandlerId(int(cs.CMMessageIdE__CMLogin), PLAYER_MGR_HANDLER_ID) cs.RegHandlerId(int(cs.CMMessageIdE__CMLogin), constant.PLAYER_MGR_HANDLER_ID)
} }
func (this *HandlerMgr) UnInit() { func (this *HandlerMgr) UnInit() {

View File

@ -11,7 +11,7 @@ import (
"ss" "ss"
proto "github.com/golang/protobuf/proto" proto "github.com/golang/protobuf/proto"
. "main/common" "main/constant"
) )
type WSPListener struct { type WSPListener struct {
@ -65,8 +65,8 @@ func (this *WSPListener) socketRead(conn net.Conn) {
for { for {
{ {
readBytes := bufLen - alreadyReadBytes readBytes := bufLen - alreadyReadBytes
if readBytes > MAX_PACKET_LEN-recvBufLen { if readBytes > constant.MAX_PACKET_LEN-recvBufLen {
readBytes = MAX_PACKET_LEN - recvBufLen readBytes = constant.MAX_PACKET_LEN - recvBufLen
} }
if readBytes > 0 { if readBytes > 0 {
@ -91,7 +91,7 @@ func (this *WSPListener) socketRead(conn net.Conn) {
copy(recvBuf[:], recvBuf[offset:]) copy(recvBuf[:], recvBuf[offset:])
} }
recvBufLen -= offset recvBufLen -= offset
if recvBufLen >= MAX_PACKET_LEN { if recvBufLen >= constant.MAX_PACKET_LEN {
panic("recv max packet") panic("recv max packet")
} }

View File

@ -7,7 +7,7 @@ import (
"fmt" "fmt"
"mt" "mt"
"q5" "q5"
"main/common" "main/constant"
) )
type playerMgr struct { type playerMgr struct {
@ -140,9 +140,9 @@ func (this *playerMgr) addSocketHash(wsp f5.WspCliConn, p *Player) {
func (this* playerMgr) ProcessCMMsg(handler *cs.CsNetMsgHandler, hdr *f5.MsgHdr) { func (this* playerMgr) ProcessCMMsg(handler *cs.CsNetMsgHandler, hdr *f5.MsgHdr) {
switch handler.HandlerId { switch handler.HandlerId {
case common.PLAYER_MGR_HANDLER_ID: case constant.PLAYER_MGR_HANDLER_ID:
cs.DispatchMsg(handler, hdr, this) cs.DispatchMsg(handler, hdr, this)
case common.PLAYER_HANDLER_ID: case constant.PLAYER_HANDLER_ID:
player := this.getPlayerBySocket(hdr.GetSocket()) player := this.getPlayerBySocket(hdr.GetSocket())
if player != nil { if player != nil {
cs.DispatchMsg(handler, hdr, player) cs.DispatchMsg(handler, hdr, player)