搜索好友

This commit is contained in:
殷勇 2023-08-15 14:19:51 +08:00
parent 0f8f37c93e
commit 0596f3519d
4 changed files with 272 additions and 70 deletions

View File

@ -22,8 +22,8 @@ CREATE TABLE `version` (
drop table if exists `t_friend_ships`; drop table if exists `t_friend_ships`;
CREATE TABLE `t_friend_ships` ( CREATE TABLE `t_friend_ships` (
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
`account1_id` varchar(60) NOT NULL, `account1_id` varchar(60) NOT NULL DEFAULT '',
`account2_id` varchar(60) NOT NULL, `account2_id` varchar(60) NOT NULL DEFAULT '',
`createtime` int NOT NULL DEFAULT '0' COMMENT '创建时间', `createtime` int NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int NOT NULL DEFAULT '0' COMMENT '修改时间', `modifytime` int NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`), PRIMARY KEY (`idx`),
@ -35,9 +35,10 @@ COMMENT "已经成为好友"
drop table if exists `t_pending_friend_requests`; drop table if exists `t_pending_friend_requests`;
CREATE TABLE t_pending_friend_requests ( CREATE TABLE t_pending_friend_requests (
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
sender_account_id varchar(60) NOT NULL, sender_account_id varchar(60) NOT NULL DEFAULT '',
receiver_account_id varchar(60) NOT NULL, receiver_account_id varchar(60) NOT NULL DEFAULT '',
request_time int DEFAULT '0', request_time int DEFAULT '0',
flag tinyint DEFAULT '0' COMMENT '0 pending, 1 ok, 2 reject',
`createtime` int NOT NULL DEFAULT '0' COMMENT '创建时间', `createtime` int NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int NOT NULL DEFAULT '0' COMMENT '修改时间', `modifytime` int NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`), PRIMARY KEY (`idx`),

View File

@ -749,6 +749,142 @@ func (x *SMReconnect) GetErrmsg() string {
return "" return ""
} }
// 请求搜索用户
type CMSearchFriend struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ServerId *int32 `protobuf:"varint,1,opt,name=server_id,json=serverId" json:"server_id,omitempty"` //保留
TeamUuid *string `protobuf:"bytes,2,opt,name=team_uuid,json=teamUuid" json:"team_uuid,omitempty"` //保留
AccountId *string `protobuf:"bytes,3,opt,name=account_id,json=accountId" json:"account_id,omitempty"` //账号id
ProtoVersion *int32 `protobuf:"varint,5,opt,name=proto_version,json=protoVersion" json:"proto_version,omitempty"` //协议版本号Constant_e.ProtoVersion
SearchKeyword *string `protobuf:"bytes,6,opt,name=search_keyword,json=searchKeyword" json:"search_keyword,omitempty"` //搜索文本关键字
SessionId *string `protobuf:"bytes,20,opt,name=session_id,json=sessionId" json:"session_id,omitempty"` //账号id
}
func (x *CMSearchFriend) Reset() {
*x = CMSearchFriend{}
if protoimpl.UnsafeEnabled {
mi := &file_cs_proto_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CMSearchFriend) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CMSearchFriend) ProtoMessage() {}
func (x *CMSearchFriend) ProtoReflect() protoreflect.Message {
mi := &file_cs_proto_proto_msgTypes[11]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CMSearchFriend.ProtoReflect.Descriptor instead.
func (*CMSearchFriend) Descriptor() ([]byte, []int) {
return file_cs_proto_proto_rawDescGZIP(), []int{11}
}
func (x *CMSearchFriend) GetServerId() int32 {
if x != nil && x.ServerId != nil {
return *x.ServerId
}
return 0
}
func (x *CMSearchFriend) GetTeamUuid() string {
if x != nil && x.TeamUuid != nil {
return *x.TeamUuid
}
return ""
}
func (x *CMSearchFriend) GetAccountId() string {
if x != nil && x.AccountId != nil {
return *x.AccountId
}
return ""
}
func (x *CMSearchFriend) GetProtoVersion() int32 {
if x != nil && x.ProtoVersion != nil {
return *x.ProtoVersion
}
return 0
}
func (x *CMSearchFriend) GetSearchKeyword() string {
if x != nil && x.SearchKeyword != nil {
return *x.SearchKeyword
}
return ""
}
func (x *CMSearchFriend) GetSessionId() string {
if x != nil && x.SessionId != nil {
return *x.SessionId
}
return ""
}
// 回复搜索用户
type SMSearchFriend struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Friends []*MFFriend `protobuf:"bytes,1,rep,name=friends" json:"friends,omitempty"`
}
func (x *SMSearchFriend) Reset() {
*x = SMSearchFriend{}
if protoimpl.UnsafeEnabled {
mi := &file_cs_proto_proto_msgTypes[12]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SMSearchFriend) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SMSearchFriend) ProtoMessage() {}
func (x *SMSearchFriend) ProtoReflect() protoreflect.Message {
mi := &file_cs_proto_proto_msgTypes[12]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SMSearchFriend.ProtoReflect.Descriptor instead.
func (*SMSearchFriend) Descriptor() ([]byte, []int) {
return file_cs_proto_proto_rawDescGZIP(), []int{12}
}
func (x *SMSearchFriend) GetFriends() []*MFFriend {
if x != nil {
return x.Friends
}
return nil
}
// 请求我的好友列表 // 请求我的好友列表
type CMListFriend struct { type CMListFriend struct {
state protoimpl.MessageState state protoimpl.MessageState
@ -765,7 +901,7 @@ type CMListFriend struct {
func (x *CMListFriend) Reset() { func (x *CMListFriend) Reset() {
*x = CMListFriend{} *x = CMListFriend{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_cs_proto_proto_msgTypes[11] mi := &file_cs_proto_proto_msgTypes[13]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -778,7 +914,7 @@ func (x *CMListFriend) String() string {
func (*CMListFriend) ProtoMessage() {} func (*CMListFriend) ProtoMessage() {}
func (x *CMListFriend) ProtoReflect() protoreflect.Message { func (x *CMListFriend) ProtoReflect() protoreflect.Message {
mi := &file_cs_proto_proto_msgTypes[11] mi := &file_cs_proto_proto_msgTypes[13]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -791,7 +927,7 @@ func (x *CMListFriend) ProtoReflect() protoreflect.Message {
// Deprecated: Use CMListFriend.ProtoReflect.Descriptor instead. // Deprecated: Use CMListFriend.ProtoReflect.Descriptor instead.
func (*CMListFriend) Descriptor() ([]byte, []int) { func (*CMListFriend) Descriptor() ([]byte, []int) {
return file_cs_proto_proto_rawDescGZIP(), []int{11} return file_cs_proto_proto_rawDescGZIP(), []int{13}
} }
func (x *CMListFriend) GetServerId() int32 { func (x *CMListFriend) GetServerId() int32 {
@ -842,7 +978,7 @@ type MFFriend struct {
func (x *MFFriend) Reset() { func (x *MFFriend) Reset() {
*x = MFFriend{} *x = MFFriend{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_cs_proto_proto_msgTypes[12] mi := &file_cs_proto_proto_msgTypes[14]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -855,7 +991,7 @@ func (x *MFFriend) String() string {
func (*MFFriend) ProtoMessage() {} func (*MFFriend) ProtoMessage() {}
func (x *MFFriend) ProtoReflect() protoreflect.Message { func (x *MFFriend) ProtoReflect() protoreflect.Message {
mi := &file_cs_proto_proto_msgTypes[12] mi := &file_cs_proto_proto_msgTypes[14]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -868,7 +1004,7 @@ func (x *MFFriend) ProtoReflect() protoreflect.Message {
// Deprecated: Use MFFriend.ProtoReflect.Descriptor instead. // Deprecated: Use MFFriend.ProtoReflect.Descriptor instead.
func (*MFFriend) Descriptor() ([]byte, []int) { func (*MFFriend) Descriptor() ([]byte, []int) {
return file_cs_proto_proto_rawDescGZIP(), []int{12} return file_cs_proto_proto_rawDescGZIP(), []int{14}
} }
func (x *MFFriend) GetAccountId() string { func (x *MFFriend) GetAccountId() string {
@ -896,7 +1032,7 @@ type SMListFriend struct {
func (x *SMListFriend) Reset() { func (x *SMListFriend) Reset() {
*x = SMListFriend{} *x = SMListFriend{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_cs_proto_proto_msgTypes[13] mi := &file_cs_proto_proto_msgTypes[15]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -909,7 +1045,7 @@ func (x *SMListFriend) String() string {
func (*SMListFriend) ProtoMessage() {} func (*SMListFriend) ProtoMessage() {}
func (x *SMListFriend) ProtoReflect() protoreflect.Message { func (x *SMListFriend) ProtoReflect() protoreflect.Message {
mi := &file_cs_proto_proto_msgTypes[13] mi := &file_cs_proto_proto_msgTypes[15]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -922,7 +1058,7 @@ func (x *SMListFriend) ProtoReflect() protoreflect.Message {
// Deprecated: Use SMListFriend.ProtoReflect.Descriptor instead. // Deprecated: Use SMListFriend.ProtoReflect.Descriptor instead.
func (*SMListFriend) Descriptor() ([]byte, []int) { func (*SMListFriend) Descriptor() ([]byte, []int) {
return file_cs_proto_proto_rawDescGZIP(), []int{13} return file_cs_proto_proto_rawDescGZIP(), []int{15}
} }
func (x *SMListFriend) GetFriends() []*MFFriend { func (x *SMListFriend) GetFriends() []*MFFriend {
@ -994,29 +1130,46 @@ var file_cs_proto_proto_rawDesc = []byte{
0x53, 0x4d, 0x52, 0x65, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x53, 0x4d, 0x52, 0x65, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x65,
0x72, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x65, 0x72, 0x72, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x65, 0x72,
0x72, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x72, 0x72, 0x6d, 0x73, 0x67, 0x18, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x72, 0x72, 0x6d, 0x73, 0x67, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x65, 0x72, 0x72, 0x6d, 0x73, 0x67, 0x22, 0xab, 0x01, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x65, 0x72, 0x72, 0x6d, 0x73, 0x67, 0x22, 0xd4, 0x01,
0x0a, 0x0c, 0x43, 0x4d, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x12, 0x1b, 0x0a, 0x0e, 0x43, 0x4d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64,
0x0a, 0x09, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20,
0x05, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x01, 0x28, 0x05, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1b, 0x0a,
0x65, 0x61, 0x6d, 0x5f, 0x75, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x09, 0x74, 0x65, 0x61, 0x6d, 0x5f, 0x75, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x74, 0x65, 0x61, 0x6d, 0x55, 0x75, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x63, 0x63, 0x6f, 0x52, 0x08, 0x74, 0x65, 0x61, 0x6d, 0x55, 0x75, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x63,
0x75, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09,
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x72, 0x6f,
0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x74, 0x6f, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x52, 0x0c, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x25,
0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x0a, 0x0e, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x5f, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64,
0x52, 0x09, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0x45, 0x0a, 0x08, 0x4d, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x4b, 0x65,
0x46, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e,
0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x63, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x73, 0x73, 0x69,
0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0x38, 0x0a, 0x0e, 0x53, 0x4d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68,
0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x12, 0x26, 0x0a, 0x07, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64,
0x6d, 0x65, 0x22, 0x36, 0x0a, 0x0c, 0x53, 0x4d, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x72, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x63, 0x73, 0x2e, 0x4d, 0x46, 0x46,
0x6e, 0x64, 0x12, 0x26, 0x0a, 0x07, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x07, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x22, 0xab,
0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x63, 0x73, 0x2e, 0x4d, 0x46, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x01, 0x0a, 0x0c, 0x43, 0x4d, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x12,
0x64, 0x52, 0x07, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x2a, 0x22, 0x0a, 0x0a, 0x43, 0x6f, 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x5f, 0x65, 0x12, 0x14, 0x0a, 0x0c, 0x50, 0x72, 0x6f, 0x74, 0x28, 0x05, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09,
0x6f, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x10, 0xd1, 0xa2, 0xd5, 0xc4, 0x07, 0x42, 0x06, 0x74, 0x65, 0x61, 0x6d, 0x5f, 0x75, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x5a, 0x04, 0x2e, 0x3b, 0x63, 0x73, 0x08, 0x74, 0x65, 0x61, 0x6d, 0x55, 0x75, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x63, 0x63,
0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61,
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52,
0x0c, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a,
0x0a, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x14, 0x20, 0x01, 0x28,
0x09, 0x52, 0x09, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0x45, 0x0a, 0x08,
0x4d, 0x46, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x63, 0x63, 0x6f,
0x75, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x63,
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e,
0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e,
0x61, 0x6d, 0x65, 0x22, 0x36, 0x0a, 0x0c, 0x53, 0x4d, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x72, 0x69,
0x65, 0x6e, 0x64, 0x12, 0x26, 0x0a, 0x07, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x18, 0x01,
0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x63, 0x73, 0x2e, 0x4d, 0x46, 0x46, 0x72, 0x69, 0x65,
0x6e, 0x64, 0x52, 0x07, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x2a, 0x22, 0x0a, 0x0a, 0x43,
0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x5f, 0x65, 0x12, 0x14, 0x0a, 0x0c, 0x50, 0x72, 0x6f,
0x74, 0x6f, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x10, 0xd1, 0xa2, 0xd5, 0xc4, 0x07, 0x42,
0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x63, 0x73,
} }
var ( var (
@ -1032,7 +1185,7 @@ func file_cs_proto_proto_rawDescGZIP() []byte {
} }
var file_cs_proto_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_cs_proto_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_cs_proto_proto_msgTypes = make([]protoimpl.MessageInfo, 14) var file_cs_proto_proto_msgTypes = make([]protoimpl.MessageInfo, 16)
var file_cs_proto_proto_goTypes = []interface{}{ var file_cs_proto_proto_goTypes = []interface{}{
(ConstantE)(0), // 0: cs.Constant_e (ConstantE)(0), // 0: cs.Constant_e
(*CMPing)(nil), // 1: cs.CMPing (*CMPing)(nil), // 1: cs.CMPing
@ -1046,17 +1199,20 @@ var file_cs_proto_proto_goTypes = []interface{}{
(*SMLogin)(nil), // 9: cs.SMLogin (*SMLogin)(nil), // 9: cs.SMLogin
(*CMReconnect)(nil), // 10: cs.CMReconnect (*CMReconnect)(nil), // 10: cs.CMReconnect
(*SMReconnect)(nil), // 11: cs.SMReconnect (*SMReconnect)(nil), // 11: cs.SMReconnect
(*CMListFriend)(nil), // 12: cs.CMListFriend (*CMSearchFriend)(nil), // 12: cs.CMSearchFriend
(*MFFriend)(nil), // 13: cs.MFFriend (*SMSearchFriend)(nil), // 13: cs.SMSearchFriend
(*SMListFriend)(nil), // 14: cs.SMListFriend (*CMListFriend)(nil), // 14: cs.CMListFriend
(*MFFriend)(nil), // 15: cs.MFFriend
(*SMListFriend)(nil), // 16: cs.SMListFriend
} }
var file_cs_proto_proto_depIdxs = []int32{ var file_cs_proto_proto_depIdxs = []int32{
13, // 0: cs.SMListFriend.friends:type_name -> cs.MFFriend 15, // 0: cs.SMSearchFriend.friends:type_name -> cs.MFFriend
1, // [1:1] is the sub-list for method output_type 15, // 1: cs.SMListFriend.friends:type_name -> cs.MFFriend
1, // [1:1] is the sub-list for method input_type 2, // [2:2] is the sub-list for method output_type
1, // [1:1] is the sub-list for extension type_name 2, // [2:2] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension extendee 2, // [2:2] is the sub-list for extension type_name
0, // [0:1] is the sub-list for field type_name 2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
} }
func init() { file_cs_proto_proto_init() } func init() { file_cs_proto_proto_init() }
@ -1198,7 +1354,7 @@ func file_cs_proto_proto_init() {
} }
} }
file_cs_proto_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { file_cs_proto_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CMListFriend); i { switch v := v.(*CMSearchFriend); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@ -1210,7 +1366,7 @@ func file_cs_proto_proto_init() {
} }
} }
file_cs_proto_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { file_cs_proto_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*MFFriend); i { switch v := v.(*SMSearchFriend); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@ -1222,6 +1378,30 @@ func file_cs_proto_proto_init() {
} }
} }
file_cs_proto_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { file_cs_proto_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CMListFriend); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_cs_proto_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*MFFriend); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_cs_proto_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SMListFriend); i { switch v := v.(*SMListFriend); i {
case 0: case 0:
return &v.state return &v.state
@ -1240,7 +1420,7 @@ func file_cs_proto_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_cs_proto_proto_rawDesc, RawDescriptor: file_cs_proto_proto_rawDesc,
NumEnums: 1, NumEnums: 1,
NumMessages: 14, NumMessages: 16,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },

View File

@ -4,7 +4,6 @@ import (
"cs" "cs"
"errors" "errors"
"f5" "f5"
"fmt"
"mt" "mt"
"q5" "q5"
"strings" "strings"
@ -50,16 +49,22 @@ func (fm *FriendsMgr) unInit() {
// 2. Struct Data Persist to DB // 2. Struct Data Persist to DB
} }
func (fm *FriendsMgr) searchFriends(usernameKeyword string) []*User { func (fm *FriendsMgr) CMSearchFriends(hdr *f5.MsgHdr, msg *cs.CMSearchFriend) {
var results []*User searchKeyword := msg.GetSearchKeyword()
lowercaseQuery := strings.ToLower(usernameKeyword) listFriend := &cs.SMSearchFriend{}
lowercaseQuery := strings.ToLower(searchKeyword)
for _, user := range fm.users { for _, user := range fm.users {
if strings.Contains(strings.ToLower(user.UserName), lowercaseQuery) { if strings.Contains(strings.ToLower(user.UserName), lowercaseQuery) {
results = append(results, user) friend := &cs.MFFriend{
AccountId: &user.AccountId,
Username: &user.UserName,
}
listFriend.Friends = append(listFriend.Friends, friend)
} }
} }
// Search result save to cached, key: keyword, value: serialization(result), expired: 2days f5.GetSysLog().Info("CMSearchFriends search result:%d\n", len(listFriend.Friends))
return results // By default, Search result save to redis..., key: search keyword, value: serialization(search result), expired: 2days
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, listFriend)
} }
// AddFriendRequest 发送好友请求 // AddFriendRequest 发送好友请求
@ -119,7 +124,7 @@ func (fm *FriendsMgr) CMListFriend(hdr *f5.MsgHdr, msg *cs.CMListFriend) {
listFriend.Friends = append(listFriend.Friends, friend) listFriend.Friends = append(listFriend.Friends, friend)
} }
} }
fmt.Printf("my friends count:%d\n", len(listFriend.Friends)) f5.GetSysLog().Info("CMListFriend friends count:%d\n", len(listFriend.Friends))
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, listFriend) wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, listFriend)
} }

View File

@ -118,6 +118,22 @@ message SMReconnect
} }
//
message CMSearchFriend
{
optional int32 server_id = 1; //
optional string team_uuid = 2; //
optional string account_id = 3; //id
optional int32 proto_version = 5; //Constant_e.ProtoVersion
optional string search_keyword = 6; //
optional string session_id = 20; //id
}
//
message SMSearchFriend
{
repeated MFFriend friends = 1;
}
// //
message CMListFriend message CMListFriend
{ {