This commit is contained in:
aozhiwei 2024-04-04 14:15:11 +08:00
parent e4303e3f02
commit 98a20af7c2
2 changed files with 12 additions and 8 deletions

View File

@ -36,6 +36,11 @@ const (
GAME_ID = 2006
)
const (
MEMBER_LOCK_KEY = "member:"
GUILD_LOCK_KEY = "guild:"
)
// im server chat
const (
CCBegin = iota

View File

@ -153,10 +153,6 @@ func (this* guildMgr) removeUsingName(name string) {
delete(this.usingNameHash, name)
}
func (this* guildMgr) genMemberLockKeys(accountIds []string) []string {
return accountIds
}
func (this *guildMgr) asyncCreateGuildTask(task *f5.AsyncTask, accountId string, avatar int32, name string,
cb func(int32, string, int64)) {
if this.internalGetGuildByAccountId(accountId) != nil {
@ -240,8 +236,9 @@ func (this *guildMgr) asyncCreateGuildTask(task *f5.AsyncTask, accountId string,
func (this *guildMgr) AsyncCreateGuild(accountId string, avatar int32, name string,
cb func(int32, string, int64)) {
lockKeys := this.genMemberLockKeys([]string{accountId})
f5.GetApp().AsyncLock(lockKeys,
f5.GetApp().AsyncLock([][]string{
{constant.MEMBER_LOCK_KEY, accountId},
},
f5.NewAsyncTask(
func (task *f5.AsyncTask) {
this.asyncCreateGuildTask(task, accountId, avatar, name, cb)
@ -324,8 +321,10 @@ func (this *guildMgr) asyncAcceptApplyTask(task *f5.AsyncTask,
}
func (this *guildMgr) AsyncAcceptApply(accountId string, targetId string, cb func(int32, string)) {
lockKeys := this.genMemberLockKeys([]string{accountId})
f5.GetApp().AsyncLock(lockKeys,
f5.GetApp().AsyncLock([][]string{
{constant.MEMBER_LOCK_KEY, accountId},
{constant.MEMBER_LOCK_KEY, targetId},
},
f5.NewAsyncTask(
func (task *f5.AsyncTask) {
this.asyncAcceptApplyTask(task, accountId, targetId, cb)