mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-11-04 11:22:10 +08:00
feat 新增了注释
This commit is contained in:
parent
44fe175ed8
commit
ba5b7c0e7e
@ -12,7 +12,7 @@ func main() {
|
|||||||
rpcServer := rpcChat.NewRpcChatServer(*rpcPort)
|
rpcServer := rpcChat.NewRpcChatServer(*rpcPort)
|
||||||
// register widgets
|
// register widgets
|
||||||
|
|
||||||
// mock
|
// mock 注册发送前的拦截器
|
||||||
rpcServer.UseWidgetBeforSend(widget.MockBeforeSendHandler)
|
rpcServer.UseWidgetBeforSend(widget.MockBeforeSendHandler)
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@ -5,13 +5,17 @@ import (
|
|||||||
pbChat "Open_IM/pkg/proto/chat"
|
pbChat "Open_IM/pkg/proto/chat"
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MockBeforeSendHandler is a mock handle that handles custom logic before send msg.
|
// MockBeforeSendHandler is a mock handle that handles custom logic before send msg.
|
||||||
func MockBeforeSendHandler(ctx context.Context, pb *pbChat.SendMsgReq) (*pbChat.SendMsgResp, bool, error) {
|
func MockBeforeSendHandler(ctx context.Context, pb *pbChat.SendMsgReq) (*pbChat.SendMsgResp, bool, error) {
|
||||||
|
fmt.Printf("MockBeforeSendHandler trigger,contentType:%d\n", pb.MsgData.GetContentType())
|
||||||
if pb.MsgData.ContentType == constant.Text {
|
if pb.MsgData.ContentType == constant.Text {
|
||||||
msg := string(pb.MsgData.Content)
|
msg := string(pb.MsgData.Content)
|
||||||
|
fmt.Printf("text msg:%s", msg)
|
||||||
if msg == "this is a m..m..mock msg" {
|
if msg == "this is a m..m..mock msg" {
|
||||||
|
fmt.Println(".==>msg had banned")
|
||||||
return nil, false, errors.New("BANG! This msg has been banned by MockBeforeSendHandler")
|
return nil, false, errors.New("BANG! This msg has been banned by MockBeforeSendHandler")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user