This commit is contained in:
aozhiwei 2024-03-21 16:08:07 +08:00
parent 66c187a52c
commit d917c28547
3 changed files with 17 additions and 11 deletions

View File

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

View File

@ -40,7 +40,7 @@ func (this *WSPListener) unInit() {
func (this *WSPListener) SS_ping(hdr *f5.MsgHdr, msg *ss.SS_Ping) {
rspMsg := ss.SS_Pong{}
this.sendProxyMsg(hdr.Conn, 0, &rspMsg)
this.SendProxyMsg(hdr.Conn, 0, &rspMsg)
}
func (this *WSPListener) SS_WSP_SocketDisconnect(hdr *f5.MsgHdr, msg *ss.SS_WSP_SocketDisconnect) {
@ -160,7 +160,7 @@ func (this *WSPListener) parseNetPkt() {
}
}
func (this *WSPListener) sendProxyMsg(conn net.Conn, socketHandle uint16, msg proto.Message) {
func (this *WSPListener) SendProxyMsg(conn net.Conn, socketHandle uint16, msg proto.Message) {
netMsg := msg.(f5.NetMsg)
if !f5.IsOnlineEnv() {
f5.GetSysLog().Info("%s %s", q5.GetTypeName(msg), q5.EncodeJson(msg))
@ -180,3 +180,8 @@ func (this *WSPListener) sendProxyMsg(conn net.Conn, socketHandle uint16, msg pr
copy(buff[f5.WSPROXYPACKHEAD_S_SIZE:], msgData[:])
conn.Write(buff)
}
func (this *WSPListener) SendProxyErrMsg(conn net.Conn, socketHandle, uint16, msg proto.Message,
errCode int32, errMsg string) {
}

View File

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