feat 模块增加after start
This commit is contained in:
@@ -1,5 +1,17 @@
|
||||
package global
|
||||
|
||||
var ServiceStatus = ServiceStatusStarting
|
||||
|
||||
type ServiceStatusCode int32
|
||||
|
||||
const (
|
||||
ServiceStatusStarting ServiceStatusCode = iota // 启动中
|
||||
ServiceStatusReady // 就绪
|
||||
ServiceStatusStopping // 停止中
|
||||
)
|
||||
|
||||
var GatewaySID string
|
||||
|
||||
const (
|
||||
KeyGatewayAccessToken = "gateway:token:access:%v"
|
||||
KeyGatewayRefreshToken = "gateway:token:refresh:%v"
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"git.hlsq.asia/mmorpg/service-common/discover/common"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/grpc/service"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/handler/ws_handler/client"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/global"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
@@ -33,7 +33,7 @@ func (s *Server) OnCustomGrpcServerOption() []grpc.ServerOption {
|
||||
}
|
||||
|
||||
func (s *Server) OnInit(serve *grpc.Server) {
|
||||
client.GatewaySID = s.SID
|
||||
global.GatewaySID = s.SID
|
||||
grpc_pb.RegisterGatewayServer(serve, s)
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
var GatewaySID string
|
||||
|
||||
type Client struct {
|
||||
sync.WaitGroup
|
||||
conn socket.ISocketConn // Socket
|
||||
|
||||
@@ -45,7 +45,7 @@ func (c *Client) handle(event Event) {
|
||||
if c.Status == 0 {
|
||||
c.Status = 1
|
||||
UserMgr.Add(c.USN, c)
|
||||
redis.GetClient().HSet(c.ctx, fmt.Sprintf(global.KeyGatewayInfo, c.USN), global.HFieldInfoGatewaySID, GatewaySID)
|
||||
redis.GetClient().HSet(c.ctx, fmt.Sprintf(global.KeyGatewayInfo, c.USN), global.HFieldInfoGatewaySID, global.GatewaySID)
|
||||
c.WriteMessage(ss_pb.MessageID_MESSAGE_ID_LOGIN_SUCCESS, &ss_pb.S2C_LoginSuccess{
|
||||
InstanceID: 1,
|
||||
})
|
||||
@@ -61,7 +61,7 @@ func (c *Client) onEnter(msg *ss_pb.C2S_EnterInstance) {
|
||||
}
|
||||
resp, err := client.Enter(c.ctx, &grpc_pb.EnterReq{
|
||||
USN: c.USN,
|
||||
GatewaySID: GatewaySID,
|
||||
GatewaySID: global.GatewaySID,
|
||||
InstanceID: msg.InstanceID,
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user