mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-26 11:36:44 +08:00
ws update
This commit is contained in:
parent
7975a377a0
commit
9843d5c7ba
@ -143,6 +143,7 @@ func (c *Client) handleMessage(message []byte) error {
|
|||||||
return utils.Wrap(errors.New("exception conn userID not same to req userID"), binaryReq.String())
|
return utils.Wrap(errors.New("exception conn userID not same to req userID"), binaryReq.String())
|
||||||
}
|
}
|
||||||
ctx := mcontext.WithMustInfoCtx([]string{binaryReq.OperationID, binaryReq.SendID, constant.PlatformIDToName(c.platformID), c.ctx.GetConnID()})
|
ctx := mcontext.WithMustInfoCtx([]string{binaryReq.OperationID, binaryReq.SendID, constant.PlatformIDToName(c.platformID), c.ctx.GetConnID()})
|
||||||
|
log.ZDebug(ctx, "gateway req message", "req", binaryReq.String())
|
||||||
var messageErr error
|
var messageErr error
|
||||||
var resp []byte
|
var resp []byte
|
||||||
switch binaryReq.ReqIdentifier {
|
switch binaryReq.ReqIdentifier {
|
||||||
@ -161,7 +162,7 @@ func (c *Client) handleMessage(message []byte) error {
|
|||||||
default:
|
default:
|
||||||
return errors.New(fmt.Sprintf("ReqIdentifier failed,sendID:%d,msgIncr:%s,reqIdentifier:%s", binaryReq.SendID, binaryReq.MsgIncr, binaryReq.ReqIdentifier))
|
return errors.New(fmt.Sprintf("ReqIdentifier failed,sendID:%d,msgIncr:%s,reqIdentifier:%s", binaryReq.SendID, binaryReq.MsgIncr, binaryReq.ReqIdentifier))
|
||||||
}
|
}
|
||||||
c.replyMessage(&binaryReq, messageErr, resp)
|
c.replyMessage(ctx, &binaryReq, messageErr, resp)
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -183,7 +184,7 @@ func (c *Client) close() {
|
|||||||
c.longConnServer.UnRegister(c)
|
c.longConnServer.UnRegister(c)
|
||||||
|
|
||||||
}
|
}
|
||||||
func (c *Client) replyMessage(binaryReq *Req, err error, resp []byte) {
|
func (c *Client) replyMessage(ctx context.Context, binaryReq *Req, err error, resp []byte) {
|
||||||
errResp := apiresp.ParseError(err)
|
errResp := apiresp.ParseError(err)
|
||||||
mReply := Resp{
|
mReply := Resp{
|
||||||
ReqIdentifier: binaryReq.ReqIdentifier,
|
ReqIdentifier: binaryReq.ReqIdentifier,
|
||||||
@ -193,7 +194,11 @@ func (c *Client) replyMessage(binaryReq *Req, err error, resp []byte) {
|
|||||||
ErrMsg: errResp.ErrMsg,
|
ErrMsg: errResp.ErrMsg,
|
||||||
Data: resp,
|
Data: resp,
|
||||||
}
|
}
|
||||||
_ = c.writeBinaryMsg(mReply)
|
log.ZDebug(ctx, "gateway reply message", "resp", mReply.String())
|
||||||
|
err = c.writeBinaryMsg(mReply)
|
||||||
|
if err != nil {
|
||||||
|
log.ZWarn(ctx, "wireBinaryMsg replyMessage", err, "resp", mReply.String())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
func (c *Client) PushMessage(ctx context.Context, msgData *sdkws.MsgData) error {
|
func (c *Client) PushMessage(ctx context.Context, msgData *sdkws.MsgData) error {
|
||||||
data, err := proto.Marshal(msgData)
|
data, err := proto.Marshal(msgData)
|
||||||
|
@ -31,6 +31,11 @@ type Resp struct {
|
|||||||
ErrMsg string `json:"errMsg"`
|
ErrMsg string `json:"errMsg"`
|
||||||
Data []byte `json:"data"`
|
Data []byte `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Resp) String() string {
|
||||||
|
return utils.StructToJsonString(r)
|
||||||
|
}
|
||||||
|
|
||||||
type MessageHandler interface {
|
type MessageHandler interface {
|
||||||
GetSeq(context context.Context, data Req) ([]byte, error)
|
GetSeq(context context.Context, data Req) ([]byte, error)
|
||||||
SendMessage(context context.Context, data Req) ([]byte, error)
|
SendMessage(context context.Context, data Req) ([]byte, error)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user