feat 新增了注释

pull/145/head
ltf 4 years ago
parent 44fe175ed8
commit ba5b7c0e7e

@ -12,7 +12,7 @@ func main() {
rpcServer := rpcChat.NewRpcChatServer(*rpcPort)
// register widgets
// mock
// mock 注册发送前的拦截器
rpcServer.UseWidgetBeforSend(widget.MockBeforeSendHandler)
//

@ -5,13 +5,17 @@ import (
pbChat "Open_IM/pkg/proto/chat"
"context"
"errors"
"fmt"
)
// MockBeforeSendHandler is a mock handle that handles custom logic before send msg.
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 {
msg := string(pb.MsgData.Content)
fmt.Printf("text msg:%s", 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")
}
}

Loading…
Cancel
Save