This commit is contained in:
Gordon 2021-10-25 21:44:18 +08:00
parent 7b96810d8f
commit 10d350942c

View File

@ -11,6 +11,7 @@ import (
"bytes" "bytes"
"context" "context"
"encoding/gob" "encoding/gob"
"encoding/json"
"fmt" "fmt"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
@ -104,26 +105,26 @@ func (ws *WServer) newestSeqReq(conn *UserConn, m *Req) {
func (ws *WServer) pullMsgResp(conn *UserConn, m *Req, pb *pbChat.PullMessageResp) { func (ws *WServer) pullMsgResp(conn *UserConn, m *Req, pb *pbChat.PullMessageResp) {
log.NewInfo(m.OperationID, "pullMsgResp come here ", pb.String()) log.NewInfo(m.OperationID, "pullMsgResp come here ", pb.String())
var mReplyData pbWs.PullMessageBySeqListResp var mReplyData pbWs.PullMessageBySeqListResp
b, err := proto.Marshal(pb) a, err := json.Marshal(pb.SingleUserMsg)
if err != nil { if err != nil {
log.NewError(m.OperationID, "GetSingleUserMsg,json marshal,err", err.Error()) log.NewError(m.OperationID, "GetSingleUserMsg,json marshal,err", err.Error())
} }
log.NewInfo(m.OperationID, "pullMsgResp json is ", len(pb.SingleUserMsg)) log.NewInfo(m.OperationID, "pullMsgResp json is ", len(pb.SingleUserMsg))
err = proto.Unmarshal(b, &mReplyData) err = json.Unmarshal(a, &mReplyData.SingleUserMsg)
if err != nil { if err != nil {
log.NewError(m.OperationID, "SingleUserMsg,json Unmarshal,err", err.Error()) log.NewError(m.OperationID, "SingleUserMsg,json Unmarshal,err", err.Error())
} }
b, err := json.Marshal(pb.GroupUserMsg)
c, err := proto.Marshal(&mReplyData)
if err != nil { if err != nil {
log.NewError(m.OperationID, "mReplyData,json marshal,err", err.Error()) log.NewError(m.OperationID, "mReplyData,json marshal,err", err.Error())
} }
var test pbWs.PullMessageBySeqListResp err = json.Unmarshal(b, &mReplyData.GroupUserMsg)
err = proto.Unmarshal(c, &test)
if err != nil { if err != nil {
log.NewError(m.OperationID, "test SingleUserMsg,json Unmarshal,err", err.Error()) log.NewError(m.OperationID, "test SingleUserMsg,json Unmarshal,err", err.Error())
} }
log.NewInfo(m.OperationID, "test info is ", len(test.SingleUserMsg), test.SingleUserMsg) c, err := proto.Marshal(&mReplyData)
log.NewInfo(m.OperationID, "test info is ", len(mReplyData.SingleUserMsg), mReplyData.SingleUserMsg)
mReply := Resp{ mReply := Resp{
ReqIdentifier: m.ReqIdentifier, ReqIdentifier: m.ReqIdentifier,
MsgIncr: m.MsgIncr, MsgIncr: m.MsgIncr,
@ -133,7 +134,7 @@ func (ws *WServer) pullMsgResp(conn *UserConn, m *Req, pb *pbChat.PullMessageRes
Data: c, Data: c,
} }
log.NewInfo(m.OperationID, "pullMsgResp all data is ", mReply.ReqIdentifier, mReply.MsgIncr, mReply.ErrCode, mReply.ErrMsg, log.NewInfo(m.OperationID, "pullMsgResp all data is ", mReply.ReqIdentifier, mReply.MsgIncr, mReply.ErrCode, mReply.ErrMsg,
mReply.OperationID) len(mReply.Data))
ws.sendMsg(conn, mReply) ws.sendMsg(conn, mReply)