This commit is contained in:
aozhiwei 2024-03-21 17:09:34 +08:00
parent d917c28547
commit 14d9884bba
5 changed files with 21 additions and 18 deletions

View File

@ -33,7 +33,6 @@ type LoginRsp struct {
type WspListener interface { type WspListener interface {
ProcessSSMMsg(*ss.SsNetMsgHandler, *f5.MsgHdr) ProcessSSMMsg(*ss.SsNetMsgHandler, *f5.MsgHdr)
SendProxyMsg(net.Conn, uint16, proto.Message) SendProxyMsg(net.Conn, uint16, proto.Message)
SendProxyErrMsg(net.Conn, uint16, proto.Message, int32, string)
} }
type App interface { type App interface {

View File

@ -10,6 +10,12 @@ type CsNetMsgHandler f5.NetMsgHandler[MsgHandler];
type MsgHandlerImpl struct { type MsgHandlerImpl struct {
} }
func (this *SMLogin) Err(errCode int32, errMsg string) *SMLogin {
this.Errcode = proto.Int32(errCode)
this.Errmsg = proto.String(errMsg)
return nil
}
var handlers [2000]*CsNetMsgHandler var handlers [2000]*CsNetMsgHandler
func GetNetMsgHandler(msgId uint16) *CsNetMsgHandler { func GetNetMsgHandler(msgId uint16) *CsNetMsgHandler {
@ -979,4 +985,4 @@ func init() {
}, },
} }
} }

View File

@ -180,8 +180,3 @@ func (this *WSPListener) SendProxyMsg(conn net.Conn, socketHandle uint16, msg pr
copy(buff[f5.WSPROXYPACKHEAD_S_SIZE:], msgData[:]) copy(buff[f5.WSPROXYPACKHEAD_S_SIZE:], msgData[:])
conn.Write(buff) conn.Write(buff)
} }
func (this *WSPListener) SendProxyErrMsg(conn net.Conn, socketHandle, uint16, msg proto.Message,
errCode int32, errMsg string) {
}

View File

@ -137,22 +137,25 @@ func (this *playerMgr) apiAuthCb(hdr *f5.MsgHdr, msg *cs.CMLogin, reqId int64,
rspMsg := cs.SMLogin{} rspMsg := cs.SMLogin{}
if rsp.GetErr() != nil { if rsp.GetErr() != nil {
GetWspListener().SendProxyErrMsg(pendingReq.hdr.Conn, pendingReq.hdr.SocketHandle, &rspMsg, GetWspListener().SendProxyMsg(pendingReq.hdr.Conn, pendingReq.hdr.SocketHandle,
2, rspMsg.Err(
"server internal error") 2,
"server internal error"))
f5.GetSysLog().Info("Api服务器JSON 解析错误1\n") f5.GetSysLog().Info("Api服务器JSON 解析错误1\n")
return return
} }
if !rsp.JsonParseOk() { if !rsp.JsonParseOk() {
GetWspListener().SendProxyErrMsg(pendingReq.hdr.Conn, pendingReq.hdr.SocketHandle, &rspMsg, GetWspListener().SendProxyMsg(pendingReq.hdr.Conn, pendingReq.hdr.SocketHandle,
2, rspMsg.Err(
"server internal error") 2,
"server internal error"))
return return
} }
if rspObj.Errcode != 0 { if rspObj.Errcode != 0 {
GetWspListener().SendProxyErrMsg(pendingReq.hdr.Conn, pendingReq.hdr.SocketHandle, &rspMsg, GetWspListener().SendProxyMsg(pendingReq.hdr.Conn, pendingReq.hdr.SocketHandle,
1, rspMsg.Err(
"invalid session_id") 2,
"invalid session_id"))
f5.GetSysLog().Error("Api服务器errcode:%d", rspObj.Errcode) f5.GetSysLog().Error("Api服务器errcode:%d", rspObj.Errcode)
return return
} }

View File

@ -24,9 +24,9 @@ type pendingLoginRequest struct {
type playerMgr struct { type playerMgr struct {
cs.MsgHandlerImpl cs.MsgHandlerImpl
socketHash map[f5.WspCliConn]*player socketHash map[f5.WspCliConn]*player
pendingLoginHash map[string]*pendingLoginRequest pendingLoginHash map[string]*pendingLoginRequest
currReqId int64 currReqId int64
} }
func (this *playerMgr) Init() { func (this *playerMgr) Init() {