瀏覽代碼

update

master
DengBiao 2 年之前
父節點
當前提交
1040113a4d
共有 4 個檔案被更改,包括 24 行新增12 行删除
  1. +10
    -1
      internal/logic/api/logic_ext.go
  2. +5
    -3
      internal/logic/api/logic_ext_test.go
  3. +8
    -7
      pkg/pb/logic.ext.pb.go
  4. +1
    -1
      test/tcp_conn/main.go

+ 10
- 1
internal/logic/api/logic_ext.go 查看文件

@@ -5,6 +5,7 @@ import (
"gim/internal/logic/app"
"gim/pkg/grpclib"
"gim/pkg/pb"
"google.golang.org/protobuf/proto"
)

type LogicExtServer struct{}
@@ -21,7 +22,15 @@ func (*LogicExtServer) SendMessage(ctx context.Context, in *pb.SendMessageReq) (
if err != nil {
return nil, err
}

if in.MessageContentBack != "" {
buf, err := proto.Marshal(&pb.Text{
Text: "hello world!",
})
if err != nil {
return nil, err
}
in.MessageContent = buf
}
sender := pb.Sender{
SenderType: pb.SenderType_ST_USER,
SenderId: userId,


+ 5
- 3
internal/logic/api/logic_ext_test.go 查看文件

@@ -26,10 +26,10 @@ func getLogicExtClient() pb.LogicExtClient {
// deprecated:

func getCtx() context.Context {
token := "0"
token := "VRZWQVPFXHPUCCKFOANEYOLCDSFMKEAVYVMAZQWQ"
return metadata.NewOutgoingContext(context.TODO(), metadata.Pairs(
"user_id", "2",
"device_id", "1",
"device_id", "2",
"token", token,
"request_id", strconv.FormatInt(time.Now().UnixNano(), 10)))
}
@@ -52,12 +52,14 @@ func TestLogicExtServer_RegisterDevice(t *testing.T) {

func TestLogicExtServer_SendMessage(t *testing.T) {
buf, err := proto.Marshal(&pb.Text{
Text: "hello alber ",
Text: "hello world!",
})
if err != nil {
fmt.Println(err)
return
}
var one = string(buf)
fmt.Printf(one)
resp, err := getLogicExtClient().SendMessage(getCtx(),
&pb.SendMessageReq{
ReceiverType: pb.ReceiverType_RT_USER,


+ 8
- 7
pkg/pb/logic.ext.pb.go 查看文件

@@ -204,13 +204,14 @@ type SendMessageReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields

ReceiverType ReceiverType `protobuf:"varint,1,opt,name=receiver_type,json=receiverType,proto3,enum=pb.ReceiverType" json:"receiver_type,omitempty"` // 接收者类型,1:user;2:group
ReceiverId int64 `protobuf:"varint,2,opt,name=receiver_id,json=receiverId,proto3" json:"receiver_id,omitempty"` // 用户id或者群组id
ToUserIds []int64 `protobuf:"varint,3,rep,packed,name=to_user_ids,json=toUserIds,proto3" json:"to_user_ids,omitempty"` // 需要@的用户id列表
MessageType MessageType `protobuf:"varint,4,opt,name=message_type,json=messageType,proto3,enum=pb.MessageType" json:"message_type,omitempty"` // 消息类型
MessageContent []byte `protobuf:"bytes,5,opt,name=message_content,json=messageContent,proto3" json:"message_content,omitempty"` // 消息内容
SendTime int64 `protobuf:"varint,6,opt,name=send_time,json=sendTime,proto3" json:"send_time,omitempty"` // 消息发送时间戳,精确到毫秒
IsPersist bool `protobuf:"varint,7,opt,name=is_persist,json=isPersist,proto3" json:"is_persist,omitempty"` // 是否将消息持久化到数据库
ReceiverType ReceiverType `protobuf:"varint,1,opt,name=receiver_type,json=receiverType,proto3,enum=pb.ReceiverType" json:"receiver_type,omitempty"` // 接收者类型,1:user;2:group
ReceiverId int64 `protobuf:"varint,2,opt,name=receiver_id,json=receiverId,proto3" json:"receiver_id,omitempty"` // 用户id或者群组id
ToUserIds []int64 `protobuf:"varint,3,rep,packed,name=to_user_ids,json=toUserIds,proto3" json:"to_user_ids,omitempty"` // 需要@的用户id列表
MessageType MessageType `protobuf:"varint,4,opt,name=message_type,json=messageType,proto3,enum=pb.MessageType" json:"message_type,omitempty"` // 消息类型
MessageContent []byte `protobuf:"bytes,5,opt,name=message_content,json=messageContent,proto3" json:"message_content,omitempty"` // 消息内容
SendTime int64 `protobuf:"varint,6,opt,name=send_time,json=sendTime,proto3" json:"send_time,omitempty"` // 消息发送时间戳,精确到毫秒
IsPersist bool `protobuf:"varint,7,opt,name=is_persist,json=isPersist,proto3" json:"is_persist,omitempty"` // 是否将消息持久化到数据库
MessageContentBack string `protobuf:"bytes,8,opt,name=message_content_back,json=messageContentBack,proto3" json:"message_content_back,omitempty"`
}

func (x *SendMessageReq) Reset() {


+ 1
- 1
test/tcp_conn/main.go 查看文件

@@ -87,7 +87,7 @@ func (c *TcpClient) SignIn() {
signIn := pb.SignInInput{
UserId: c.UserId,
DeviceId: c.DeviceId,
Token: "0",
Token: "ABPIKUKGTCZZGLUSZQAGFXKCSQFEVXEMAYHNNOUZ",
}
c.Output(pb.PackageType_PT_SIGN_IN, time.Now().UnixNano(), &signIn)
}


Loading…
取消
儲存