xy 13 tuntia sitten
vanhempi
commit
045486e4f7

+ 11 - 0
bin/client_msg/common.proto

@@ -326,4 +326,15 @@ message OptAddFriendRequest{
 
 message NotifyOptFriend{
   RequestAddFriendItem info = 1;
+}
+
+
+message SearchUser{
+  string user_id = 1;
+}
+
+message ResSearchUser{
+  bool success = 1;
+  MsgError err_msg = 2;
+  UserInfo info = 3;
 }

+ 1 - 0
src/server/gate/router.go

@@ -18,6 +18,7 @@ func init() {
 
 	msg.Processor.SetRouter(&msg.RecvAddFriendRequest{}, hall.ChanRPC)
 	msg.Processor.SetRouter(&msg.OptAddFriendRequest{}, hall.ChanRPC)
+	msg.Processor.SetRouter(&msg.SearchUser{}, hall.ChanRPC)
 
 	msg.Processor.SetRouter(&msg.ReqHeartBeat{}, game.ChanRPC)
 	msg.Processor.SetRouter(&msg.SendColorSz{}, game.ChanRPC)

+ 26 - 0
src/server/hall/friends/friends.go

@@ -1,6 +1,7 @@
 package friends
 
 import (
+	usercenter "server/datacenter"
 	requestaddfriend "server/datacenter/request_add_friend"
 	agentmanager "server/game/agentManager"
 	"server/msg"
@@ -90,6 +91,31 @@ func NotifyOptFriend(FromUserID string, request_data *requestaddfriend.FriendReq
 	}
 }
 
+// 搜索玩家
+func SearchUser(args []interface{}) {
+	m := args[0].(*msg.SearchUser)
+	a := args[1].(gate.Agent)
+	user_data, err := usercenter.GetUserByID(m.UserId)
+	if err != nil {
+		a.WriteMsg(&msg.ResSearchUser{
+			Success: false,
+			ErrMsg: &msg.MsgError{
+				ErrorCode: 101,
+				ErrorMsg:  err.Error(),
+			},
+		})
+	} else {
+		a.WriteMsg(&msg.ResSearchUser{
+			Success: true,
+			ErrMsg:  nil,
+			Info: &msg.UserInfo{
+				MHead: user_data.Head,
+				Name:  user_data.Name,
+			},
+		})
+	}
+}
+
 // 通知给在线的好友自己上线
 
 // 通知给在线的好友自己下线

+ 2 - 1
src/server/hall/internal/handler.go

@@ -25,7 +25,8 @@ func init() {
 	HandleMsg(&msg.BuyShopItem{}, shop.OnBuy)
 	HandleMsg(&msg.ReqFriendList{}, friends.GetFriendsListByUserId)
 	HandleMsg(&msg.ReqAddFriend{}, friends.AddFriendrRquest)
-
+	HandleMsg(&msg.OptAddFriendRequest{}, friends.OptFriendrRquest)
+	HandleMsg(&msg.SearchUser{}, friends.SearchUser)
 }
 
 func enterHall(args []interface{}) {

+ 123 - 8
src/server/msg/common.pb.go

@@ -3024,6 +3024,110 @@ func (x *NotifyOptFriend) GetInfo() *RequestAddFriendItem {
 	return nil
 }
 
+type SearchUser struct {
+	state         protoimpl.MessageState `protogen:"open.v1"`
+	UserId        string                 `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
+	unknownFields protoimpl.UnknownFields
+	sizeCache     protoimpl.SizeCache
+}
+
+func (x *SearchUser) Reset() {
+	*x = SearchUser{}
+	mi := &file_common_proto_msgTypes[45]
+	ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+	ms.StoreMessageInfo(mi)
+}
+
+func (x *SearchUser) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*SearchUser) ProtoMessage() {}
+
+func (x *SearchUser) ProtoReflect() protoreflect.Message {
+	mi := &file_common_proto_msgTypes[45]
+	if x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use SearchUser.ProtoReflect.Descriptor instead.
+func (*SearchUser) Descriptor() ([]byte, []int) {
+	return file_common_proto_rawDescGZIP(), []int{45}
+}
+
+func (x *SearchUser) GetUserId() string {
+	if x != nil {
+		return x.UserId
+	}
+	return ""
+}
+
+type ResSearchUser struct {
+	state         protoimpl.MessageState `protogen:"open.v1"`
+	Success       bool                   `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
+	ErrMsg        *MsgError              `protobuf:"bytes,2,opt,name=err_msg,json=errMsg,proto3" json:"err_msg,omitempty"`
+	Info          *UserInfo              `protobuf:"bytes,3,opt,name=info,proto3" json:"info,omitempty"`
+	unknownFields protoimpl.UnknownFields
+	sizeCache     protoimpl.SizeCache
+}
+
+func (x *ResSearchUser) Reset() {
+	*x = ResSearchUser{}
+	mi := &file_common_proto_msgTypes[46]
+	ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+	ms.StoreMessageInfo(mi)
+}
+
+func (x *ResSearchUser) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*ResSearchUser) ProtoMessage() {}
+
+func (x *ResSearchUser) ProtoReflect() protoreflect.Message {
+	mi := &file_common_proto_msgTypes[46]
+	if x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use ResSearchUser.ProtoReflect.Descriptor instead.
+func (*ResSearchUser) Descriptor() ([]byte, []int) {
+	return file_common_proto_rawDescGZIP(), []int{46}
+}
+
+func (x *ResSearchUser) GetSuccess() bool {
+	if x != nil {
+		return x.Success
+	}
+	return false
+}
+
+func (x *ResSearchUser) GetErrMsg() *MsgError {
+	if x != nil {
+		return x.ErrMsg
+	}
+	return nil
+}
+
+func (x *ResSearchUser) GetInfo() *UserInfo {
+	if x != nil {
+		return x.Info
+	}
+	return nil
+}
+
 var File_common_proto protoreflect.FileDescriptor
 
 const file_common_proto_rawDesc = "" +
@@ -3217,7 +3321,14 @@ const file_common_proto_rawDesc = "" +
 	"\x13OptAddFriendRequest\x12)\n" +
 	"\x04info\x18\x01 \x01(\v2\x15.RequestAddFriendItemR\x04info\"<\n" +
 	"\x0fNotifyOptFriend\x12)\n" +
-	"\x04info\x18\x01 \x01(\v2\x15.RequestAddFriendItemR\x04info*K\n" +
+	"\x04info\x18\x01 \x01(\v2\x15.RequestAddFriendItemR\x04info\"%\n" +
+	"\n" +
+	"SearchUser\x12\x17\n" +
+	"\auser_id\x18\x01 \x01(\tR\x06userId\"l\n" +
+	"\rResSearchUser\x12\x18\n" +
+	"\asuccess\x18\x01 \x01(\bR\asuccess\x12\"\n" +
+	"\aerr_msg\x18\x02 \x01(\v2\t.MsgErrorR\x06errMsg\x12\x1d\n" +
+	"\x04info\x18\x03 \x01(\v2\t.UserInfoR\x04info*K\n" +
 	"\broleType\x12\x15\n" +
 	"\x11ROLE_TYPE_UNKNOWN\x10\x00\x12\a\n" +
 	"\x03RED\x10\x01\x12\b\n" +
@@ -3268,7 +3379,7 @@ func file_common_proto_rawDescGZIP() []byte {
 }
 
 var file_common_proto_enumTypes = make([]protoimpl.EnumInfo, 7)
-var file_common_proto_msgTypes = make([]protoimpl.MessageInfo, 45)
+var file_common_proto_msgTypes = make([]protoimpl.MessageInfo, 47)
 var file_common_proto_goTypes = []any{
 	(RoleType)(0),                // 0: roleType
 	(OptType)(0),                 // 1: OptType
@@ -3322,6 +3433,8 @@ var file_common_proto_goTypes = []any{
 	(*RecvAddFriendRequest)(nil), // 49: RecvAddFriendRequest
 	(*OptAddFriendRequest)(nil),  // 50: OptAddFriendRequest
 	(*NotifyOptFriend)(nil),      // 51: NotifyOptFriend
+	(*SearchUser)(nil),           // 52: SearchUser
+	(*ResSearchUser)(nil),        // 53: ResSearchUser
 }
 var file_common_proto_depIdxs = []int32{
 	0,  // 0: round.m_color:type_name -> roleType
@@ -3379,11 +3492,13 @@ var file_common_proto_depIdxs = []int32{
 	21, // 52: RecvAddFriendRequest.info:type_name -> UserInfo
 	45, // 53: OptAddFriendRequest.info:type_name -> RequestAddFriendItem
 	45, // 54: NotifyOptFriend.info:type_name -> RequestAddFriendItem
-	55, // [55:55] is the sub-list for method output_type
-	55, // [55:55] is the sub-list for method input_type
-	55, // [55:55] is the sub-list for extension type_name
-	55, // [55:55] is the sub-list for extension extendee
-	0,  // [0:55] is the sub-list for field type_name
+	31, // 55: ResSearchUser.err_msg:type_name -> MsgError
+	21, // 56: ResSearchUser.info:type_name -> UserInfo
+	57, // [57:57] is the sub-list for method output_type
+	57, // [57:57] is the sub-list for method input_type
+	57, // [57:57] is the sub-list for extension type_name
+	57, // [57:57] is the sub-list for extension extendee
+	0,  // [0:57] is the sub-list for field type_name
 }
 
 func init() { file_common_proto_init() }
@@ -3397,7 +3512,7 @@ func file_common_proto_init() {
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: unsafe.Slice(unsafe.StringData(file_common_proto_rawDesc), len(file_common_proto_rawDesc)),
 			NumEnums:      7,
-			NumMessages:   45,
+			NumMessages:   47,
 			NumExtensions: 0,
 			NumServices:   0,
 		},

+ 2 - 0
src/server/msg/msg.go

@@ -63,6 +63,8 @@ func init() {
 
 	Processor.Register(&OptAddFriendRequest{})
 
+	Processor.Register(&SearchUser{})
+
 	Processor.Range(func(id uint16, t reflect.Type) {
 		log.Debug("消息ID: %d, 消息类型: %s\n", id, t.Elem().Name())
 		msgList = append(msgList, MsgInfo{