pull/103/head
Gordon 3 years ago
parent fb5bed9cce
commit 50e344b9fb

@ -32,7 +32,7 @@ func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
err := dec.Decode(&m) err := dec.Decode(&m)
if err != nil { if err != nil {
log.ErrorByKv("ws json Unmarshal err", "", "err", err.Error()) log.ErrorByKv("ws json Unmarshal err", "", "err", err.Error())
ws.sendErrMsg(conn, 200, err.Error(), constant.WSDataError, "") ws.sendErrMsg(conn, 200, err.Error(), constant.WSDataError, "", "")
err = conn.Close() err = conn.Close()
if err != nil { if err != nil {
log.NewError("", "ws close err", err.Error()) log.NewError("", "ws close err", err.Error())
@ -41,14 +41,14 @@ func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
} }
if err := validate.Struct(m); err != nil { if err := validate.Struct(m); err != nil {
log.ErrorByKv("ws args validate err", "", "err", err.Error()) log.ErrorByKv("ws args validate err", "", "err", err.Error())
ws.sendErrMsg(conn, 201, err.Error(), m.ReqIdentifier, m.MsgIncr) ws.sendErrMsg(conn, 201, err.Error(), m.ReqIdentifier, m.MsgIncr, m.OperationID)
return return
} }
if !utils.VerifyToken(m.Token, m.SendID) { //if !utils.VerifyToken(m.Token, m.SendID) {
ws.sendErrMsg(conn, 202, "token validate err", m.ReqIdentifier, m.MsgIncr) // ws.sendErrMsg(conn, 202, "token validate err", m.ReqIdentifier, m.MsgIncr,m.OperationID)
return // return
} //}
fmt.Println("test fmt Basic Info Authentication Success", m.OperationID, "reqIdentifier", m.ReqIdentifier, "sendID", m.SendID) fmt.Println("test fmt Basic Info Authentication Success", m.OperationID, "reqIdentifier", m.ReqIdentifier, "sendID", m.SendID)
log.InfoByKv("Basic Info Authentication Success", m.OperationID, "reqIdentifier", m.ReqIdentifier, "sendID", m.SendID, "msgIncr", m.MsgIncr) log.InfoByKv("Basic Info Authentication Success", m.OperationID, "reqIdentifier", m.ReqIdentifier, "sendID", m.SendID, "msgIncr", m.MsgIncr)
@ -267,11 +267,13 @@ func (ws *WServer) sendMsg(conn *UserConn, mReply interface{}) {
log.ErrorByKv("WS WriteMsg error", "", "userIP", conn.RemoteAddr().String(), "userUid", ws.getUserUid(conn), "error", err, "mReply", mReply) log.ErrorByKv("WS WriteMsg error", "", "userIP", conn.RemoteAddr().String(), "userUid", ws.getUserUid(conn), "error", err, "mReply", mReply)
} }
} }
func (ws *WServer) sendErrMsg(conn *UserConn, errCode int32, errMsg string, reqIdentifier int32, msgIncr string) { func (ws *WServer) sendErrMsg(conn *UserConn, errCode int32, errMsg string, reqIdentifier int32, msgIncr string, operationID string) {
mReply := make(map[string]interface{}) mReply := Resp{
mReply["errCode"] = errCode ReqIdentifier: reqIdentifier,
mReply["errMsg"] = errMsg MsgIncr: msgIncr,
mReply["reqIdentifier"] = reqIdentifier ErrCode: errCode,
mReply["msgIncr"] = msgIncr ErrMsg: errMsg,
OperationID: operationID,
}
ws.sendMsg(conn, mReply) ws.sendMsg(conn, mReply)
} }

Loading…
Cancel
Save