This commit is contained in:
aozhiwei 2024-03-23 09:53:56 +08:00
parent 211cf4b785
commit 428ec197c9
3 changed files with 15 additions and 5 deletions

View File

@ -17,7 +17,7 @@ func (this *CacheMgr) init() {
func (this *CacheMgr) UnInit() {
}
func (this *CacheMgr) AsyncGetUsers(accountIds []string, cb func(bool)) {
func (this *CacheMgr) AsyncGetUsers(accountIds []string, cb func(int32, string)) {
}
@ -31,7 +31,7 @@ func (this *CacheMgr) GetUserProfile(accountId string) common.UserProfile {
func (this *CacheMgr) PreLoad(accountIds []string) {
}
func (this *CacheMgr) Search(sinceId int64, q string,
func (this *CacheMgr) AsyncSearch(sinceId int64, q string,
cb func(int32, string, int64, []string)) {
}

View File

@ -71,9 +71,9 @@ type GuildMgr interface {
type CacheMgr interface {
PreLoadUser([]string)
AsyncGetUsers([]string, func(bool))
GetUserProfile(string) UserProfile
Search(int64, string, func(int32, string, int64, []string))
AsyncGetUsers([]string, func(int32, string))
AsyncSearch(int64, string, func(int32, string, int64, []string))
}
type ChatMgr interface {

View File

@ -52,7 +52,8 @@ func (this *player) CMPing(hdr *f5.MsgHdr, msg *cs.CMPing) {
}
func (this *player) CMSearchUser(hdr *f5.MsgHdr, msg *cs.CMSearchUser) {
GetCacheMgr().Search(msg.GetSinceId(),
GetCacheMgr().AsyncSearch(
msg.GetSinceId(),
msg.GetUsername(),
func (errCode int32, errMsg string, sinceId int64, accountIds []string) {
rspMsg := new(cs.SMSearchUser)
@ -74,6 +75,15 @@ func (this *player) CMSearchUser(hdr *f5.MsgHdr, msg *cs.CMSearchUser) {
}
func (this *player) CMSearchUserByAccountId(hdr *f5.MsgHdr, msg *cs.CMSearchUserByAccountId) {
GetCacheMgr().AsyncGetUsers(
[]string{msg.GetAccountId()},
func (errCode int32, errMsg string) {
rspMsg := new(cs.SMSearchUserByAccountId)
if errCode != 0 {
this.SendMsg(rspMsg.Err(1, "internal server error"))
return
}
})
}
func (this *player) CMListPendingFriendRequest(hdr *f5.MsgHdr, msg *cs.CMListPendingFriendRequest) {