修复bug
This commit is contained in:
parent
5164e06ac1
commit
6feadbfeef
@ -17,7 +17,7 @@ const (
|
||||
|
||||
var Command *config.Command
|
||||
var Cfg *config.Common
|
||||
var GateCfg *GateConfig
|
||||
var GateCfg = &GateConfig{}
|
||||
|
||||
type GateConfig struct {
|
||||
Address []string `json:"address"` // 网关地址
|
||||
@ -39,12 +39,12 @@ func LoadConfig(GitCommit, GitBranch, BuildDate string) {
|
||||
return
|
||||
}
|
||||
defer func() { _ = rdb.Close() }()
|
||||
Cfg, err = config.LoadCommonConfig[GateConfig](rdb, GitCommit, GitBranch, BuildDate)
|
||||
Cfg, err = config.LoadCommonConfig(rdb, GitCommit, GitBranch, BuildDate)
|
||||
if err != nil {
|
||||
log.Error(err.Error())
|
||||
return
|
||||
}
|
||||
if err = config.LoadGameConfig[GateConfig](rdb, gateKey, Cfg); err != nil {
|
||||
if err = config.LoadGameConfig(rdb, gateKey, Cfg); err != nil {
|
||||
log.DebugF("load config:empty etcd key")
|
||||
GateCfg = &GateConfig{
|
||||
Address: []string{gateAddress1, gateAddress2},
|
||||
|
@ -65,11 +65,11 @@ func newGateService(serviceId int) *GateService {
|
||||
}
|
||||
|
||||
addressPos := serviceId - config.Command.ServiceId
|
||||
if len(config.Cfg.Special.Address) <= addressPos {
|
||||
if len(config.GateCfg.Address) <= addressPos {
|
||||
log.FatalF("Special address number must be greater than %d", addressPos)
|
||||
return nil
|
||||
}
|
||||
wsAddress := config.Cfg.Special.Address[addressPos]
|
||||
wsAddress := config.GateCfg.Address[addressPos]
|
||||
s.wss = ws.NewWsServer(wsAddress, s.WsOnMessage, s.WsOnDisconnect)
|
||||
s.bindService = userBindService.NewUserBindService(model.UserBindServiceRedis, s.ServiceEtcd())
|
||||
|
||||
@ -166,7 +166,11 @@ func (s *GateService) WsOnMessage(conn ws.IConn, data []byte) {
|
||||
if msg.ServiceName != "" {
|
||||
topic = service.TopicEx(msg.ServiceName)
|
||||
} else {
|
||||
topic, msg.ServiceName = s.bindService.FindTopic(conn.UserId(), msg.ServiceTid)
|
||||
if node, err := s.bindService.FindServiceNode(msg.ServiceTid, conn.UserId()); err == nil {
|
||||
topic, msg.ServiceName = service.TopicEx(node.Name), node.Name
|
||||
} else {
|
||||
log.ErrorF("uid:%v 查找节点:%v 失败:%v", conn.UserId(), msg.ServiceTid, err.Error())
|
||||
}
|
||||
}
|
||||
if topic != "" {
|
||||
if msg.MsgId == int32(pb.MsgId_ReqUserLoginId) {
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
var Command *config.Command
|
||||
var Cfg *config.Common[LoginConfig]
|
||||
var Cfg *config.Common
|
||||
|
||||
type LoginConfig struct {
|
||||
}
|
||||
@ -29,7 +29,7 @@ func LoadConfig(GitCommit, GitBranch, BuildDate string) {
|
||||
return
|
||||
}
|
||||
defer func() { _ = rdb.Close() }()
|
||||
Cfg, err = config.LoadCommonConfig[LoginConfig](rdb, GitCommit, GitBranch, BuildDate)
|
||||
Cfg, err = config.LoadCommonConfig(rdb, GitCommit, GitBranch, BuildDate)
|
||||
if err != nil {
|
||||
log.Error(err.Error())
|
||||
return
|
||||
|
@ -42,7 +42,7 @@ func (s *LoginService) checkLoginOrRegister(req *pb.ReqUserLogin) (us *user.User
|
||||
DeviceID: req.DeviceId,
|
||||
LastLoginIP: req.Ip,
|
||||
}
|
||||
rpcMsg := ipb.MakeRpcMsg[user.UserAccount](rpc.GetUserAccount, 0, us)
|
||||
rpcMsg := ipb.MakeRpcMsg(rpc.GetUserAccount, 0, us)
|
||||
rspMsg, err := s.Call(service.RpcTopicEx(node.Name), timeout, rpcMsg)
|
||||
if err != nil {
|
||||
log.ErrorF(s.Log("call rpc:%v err:%s ", rpcMsg.RpcMsgId, err.Error()))
|
||||
@ -65,7 +65,7 @@ func (s *LoginService) checkLoginOrRegister(req *pb.ReqUserLogin) (us *user.User
|
||||
RegisterIP: req.Ip,
|
||||
RegisterTime: time.Now(),
|
||||
}
|
||||
rpcMsg = ipb.MakeRpcMsg[user.UserAccount](rpc.CreateUserAccount, 0, us)
|
||||
rpcMsg = ipb.MakeRpcMsg(rpc.CreateUserAccount, 0, us)
|
||||
rspMsg, err = s.Call(service.RpcTopicEx(node.Name), timeout, rpcMsg)
|
||||
if err != nil {
|
||||
log.ErrorF(s.Log("call rpc:%v err:%s ", rpcMsg.RpcMsgId, err.Error()))
|
||||
@ -110,7 +110,7 @@ func (s *LoginService) getUser(accountId int64, tName string) (*user.User, pb.Er
|
||||
us := &user.User{
|
||||
AccountId: accountId,
|
||||
}
|
||||
rpcMsg := ipb.MakeRpcMsg[user.User](rpc.GetUserByAccountId, 0, us)
|
||||
rpcMsg := ipb.MakeRpcMsg(rpc.GetUserByAccountId, 0, us)
|
||||
rsp, err := s.Call(service.RpcTopicEx(tName), timeout, rpcMsg)
|
||||
if err != nil {
|
||||
log.ErrorF(s.Log("call rpc:%v err:%s", rpcMsg.RpcMsgId, err.Error()))
|
||||
@ -157,7 +157,7 @@ func (s *LoginService) onLoginOrRegister(iMsg *ipb.InternalMsg, req *pb.ReqUserL
|
||||
}
|
||||
switch code {
|
||||
case pb.ErrCode_LoginUserOrPwdErr, pb.ErrCode_OK:
|
||||
rpcMsg := ipb.MakeRpcMsg[user.UserLoginLog](rpc.LogUserAccountLogin, 0, loginLog)
|
||||
rpcMsg := ipb.MakeRpcMsg(rpc.LogUserAccountLogin, 0, loginLog)
|
||||
ksync.GoSafe(func() {
|
||||
_, _ = s.Call(service.RpcTopicEx(node.Name), timeout, rpcMsg)
|
||||
}, nil)
|
||||
|
Loading…
x
Reference in New Issue
Block a user