Skip to content

Commit

Permalink
111
Browse files Browse the repository at this point in the history
  • Loading branch information
bobohume committed Apr 19, 2022
1 parent 3b15ba7 commit 9143f4c
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
6 changes: 6 additions & 0 deletions common/cluster/Cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"gonet/base/vector"
"gonet/common"
"gonet/common/cluster/etv3"
"gonet/hotfix"
"gonet/network"
"gonet/rpc"
"reflect"
Expand Down Expand Up @@ -334,6 +335,11 @@ func (this *Cluster) Cluster_Del(ctx context.Context, info *common.ClusterInfo)
this.DelCluster(info)
}

//打patch
func (this *Cluster) Patch(ctx context.Context, patchName string) {
hotfix.HotFix(patchName)
}

var (
MGR Cluster
)
Expand Down
2 changes: 1 addition & 1 deletion common/cluster/et/mailbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (this *MailBox) del(info *rpc.MailBox) {
case rpc.SERVICE_GAME:
actor.MGR.SendMsg(rpc.RpcHead{Id: info.Id}, "Player.Player_On_UnRegister")
case rpc.SERVICE_GM:
actor.MGR.SendMsg(rpc.RpcHead{Id: info.Id}, "AccountMgr.Player_On_UnRegister")
actor.MGR.SendMsg(rpc.RpcHead{Id: info.Id, SendType:rpc.SEND_BOARD_CAST}, "AccountMgr.Player_On_UnRegister")
case rpc.SERVICE_DB:
actor.MGR.SendMsg(rpc.RpcHead{Id: info.Id}, "PlayerMgr.Player_On_UnRegister")
}
Expand Down
2 changes: 1 addition & 1 deletion common/cluster/etv3/mailbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (this *MailBox) del(info *rpc.MailBox) {
case rpc.SERVICE_GAME:
actor.MGR.SendMsg(rpc.RpcHead{Id: info.Id}, "Player.Player_On_UnRegister")
case rpc.SERVICE_GM:
actor.MGR.SendMsg(rpc.RpcHead{Id: info.Id}, "AccountMgr.Player_On_UnRegister")
actor.MGR.SendMsg(rpc.RpcHead{Id: info.Id, SendType:rpc.SEND_BOARD_CAST}, "AccountMgr.Player_On_UnRegister")
case rpc.SERVICE_DB:
actor.MGR.SendMsg(rpc.RpcHead{Id: info.Id}, "PlayerMgr.Player_On_UnRegister")
}
Expand Down
4 changes: 2 additions & 2 deletions server/gate/UserProcess.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ func (this *UserPrcoess) LoginAccountRequest(ctx context.Context, packet *messag
dh.Init()
dh.ExchangePubk(packet.GetKey())
this.addKey(head.SocketId, &dh)
head.Id = int64(head.SocketId)
head.Id = int64(base.GetMessageCode1(packet.AccountName))
packet.Key = dh.PubKey()
funcName := "Login.LoginAccountRequest"
this.SwtichSendToGM(head.SocketId, funcName, head, rpc.Marshal(&head, &funcName, packet))
this.SwtichSendToGM(head.SocketId, funcName, head, rpc.Marshal(&head, &funcName, packet, head.SocketId))
}

func (this *UserPrcoess) LoginPlayerRequset(ctx context.Context, packet *message.LoginPlayerRequset) {
Expand Down
16 changes: 11 additions & 5 deletions server/gm/login/AccountMgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type (

m_AccountMap map[int64]*Account
m_AccountNameMap map[string]*Account
m_PlayerMap map[int64]*Account
}

IAccountMgr interface {
Expand All @@ -34,6 +35,7 @@ func (this *AccountMgr) Init() {
this.Actor.Init()
this.m_AccountMap = make(map[int64]*Account)
this.m_AccountNameMap = make(map[string]*Account)
this.m_PlayerMap = make(map[int64]*Account)
//actor.MGR.RegisterActor(this)
this.Actor.Start()
}
Expand Down Expand Up @@ -81,12 +83,15 @@ func (this *AccountMgr) AddAccount(accountId int64) *Account {
return nil
}

func (this *AccountMgr) RemoveAccount(accountId int64) {
pAccount := this.GetAccount(accountId)
if pAccount != nil {
func (this *AccountMgr) RemoveAccount(playerId int64) {
pAccount, exist := this.m_PlayerMap[playerId]
if exist {
delete(this.m_AccountNameMap, pAccount.AccountName)
delete(this.m_AccountMap, accountId)
base.LOG.Printf("账号[%d]断开链接", accountId)
delete(this.m_AccountMap, pAccount.AccountId)
for _, v := range pAccount.PlayerSimpleDataList {
delete(this.m_PlayerMap, v.PlayerId)
}
base.LOG.Printf("账号[%d]断开链接", pAccount.AccountId)
}
}

Expand All @@ -101,6 +106,7 @@ func (this *AccountMgr) Account_Login(ctx context.Context, accountName string, a
PlayerDataList := make([]*message.PlayerData, len(pAccount.PlayerSimpleDataList))
for i, v := range pAccount.PlayerSimpleDataList {
PlayerDataList[i] = &message.PlayerData{PlayerID: v.PlayerId, PlayerName: v.PlayerName, PlayerGold: int32(v.Gold)}
this.m_PlayerMap[v.PlayerId] = pAccount
}

gm.SendToClient(rpc.RpcHead{ClusterId: id, SocketId: socketId, Id: accountId}, &message.SelectPlayerResponse{PacketHead: message.BuildPacketHead(accountId, rpc.SERVICE_GATE),
Expand Down
4 changes: 2 additions & 2 deletions server/gm/login/Login.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ func (this *Login) LoginPlayer(accountName string) (int64, error) {
}

//登录账号
func (this *Login) LoginAccountRequest(ctx context.Context, packet *message.LoginAccountRequest) {
func (this *Login) LoginAccountRequest(ctx context.Context, packet *message.LoginAccountRequest, gateSocketId uint32) {
accountName := packet.GetAccountName()
password := packet.GetPassword()
buildVersion := packet.GetBuildNo()
socketId := uint32(this.GetRpcHead(ctx).Id)
socketId := gateSocketId
key := packet.GetKey()
nError := base.NONE_ERROR

Expand Down

0 comments on commit 9143f4c

Please sign in to comment.