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