feat sc改名ss
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
||||
"git.hlsq.asia/mmorpg/service-common/db/redis"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/grpc/service"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/sc/sc_pb"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/ss/ss_pb"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/global"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/grpc_server/stream_client"
|
||||
"google.golang.org/protobuf/proto"
|
||||
@@ -16,23 +16,23 @@ import (
|
||||
func (c *Client) handle(event Event) {
|
||||
switch e := event.(type) {
|
||||
case *ClientEvent:
|
||||
msg := &sc_pb.Message{}
|
||||
msg := &ss_pb.Message{}
|
||||
if err := proto.Unmarshal(e.Msg, msg); err != nil {
|
||||
c.logger.Errorf("handle event proto.Unmarshal err: %v", err)
|
||||
c.cancel()
|
||||
return
|
||||
}
|
||||
switch msg.ID {
|
||||
case sc_pb.MessageID_MESSAGE_ID_ENTER_INSTANCE:
|
||||
m := &sc_pb.C2S_EnterInstance{}
|
||||
case ss_pb.MessageID_MESSAGE_ID_ENTER_INSTANCE:
|
||||
m := &ss_pb.C2S_EnterInstance{}
|
||||
if err := proto.Unmarshal(msg.Payload, m); err != nil {
|
||||
c.logger.Errorf("handle event proto.Unmarshal err: %v", err)
|
||||
c.cancel()
|
||||
return
|
||||
}
|
||||
c.onEnter(m)
|
||||
case sc_pb.MessageID_MESSAGE_ID_ACTION:
|
||||
m := &sc_pb.C2S_Action{}
|
||||
case ss_pb.MessageID_MESSAGE_ID_ACTION:
|
||||
m := &ss_pb.C2S_Action{}
|
||||
if err := proto.Unmarshal(msg.Payload, m); err != nil {
|
||||
c.logger.Errorf("handle event proto.Unmarshal err: %v", err)
|
||||
c.cancel()
|
||||
@@ -47,14 +47,14 @@ func (c *Client) handle(event Event) {
|
||||
c.Status = 1
|
||||
UserMgr.Add(c.USN, c)
|
||||
redis.GetClient().HSet(c.ctx, fmt.Sprintf(global.KeyGatewayInfo, c.USN), global.HFieldInfoGatewaySID, GatewaySID)
|
||||
c.WriteMessage(sc_pb.MessageID_MESSAGE_ID_LOGIN_SUCCESS, &sc_pb.S2C_LoginSuccess{
|
||||
c.WriteMessage(ss_pb.MessageID_MESSAGE_ID_LOGIN_SUCCESS, &ss_pb.S2C_LoginSuccess{
|
||||
InstanceID: 1,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) onEnter(msg *sc_pb.C2S_EnterInstance) {
|
||||
func (c *Client) onEnter(msg *ss_pb.C2S_EnterInstance) {
|
||||
client, err := service.SceneNewClientLB()
|
||||
if err != nil {
|
||||
c.logger.Errorf("SceneNewClient err: %v", err)
|
||||
@@ -72,7 +72,7 @@ func (c *Client) onEnter(msg *sc_pb.C2S_EnterInstance) {
|
||||
c.SceneSID = resp.SceneSID
|
||||
c.UniqueNo = resp.UniqueNo
|
||||
c.InstanceID = msg.InstanceID
|
||||
c.WriteBytes(sc_pb.MessageID(resp.MessageID), resp.Payload)
|
||||
c.WriteBytes(ss_pb.MessageID(resp.MessageID), resp.Payload)
|
||||
}
|
||||
|
||||
func (c *Client) onLeave() {
|
||||
@@ -94,7 +94,7 @@ func (c *Client) onLeave() {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) onAction(msg *sc_pb.C2S_Action) {
|
||||
func (c *Client) onAction(msg *ss_pb.C2S_Action) {
|
||||
if c.SceneSID == "" {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/sc/sc_pb"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/ss/ss_pb"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// WriteMessage 向客户端发送消息
|
||||
func (c *Client) WriteMessage(id sc_pb.MessageID, data proto.Message) {
|
||||
func (c *Client) WriteMessage(id ss_pb.MessageID, data proto.Message) {
|
||||
if c.conn == nil || c.conn.IsClose() {
|
||||
return
|
||||
}
|
||||
@@ -15,7 +15,7 @@ func (c *Client) WriteMessage(id sc_pb.MessageID, data proto.Message) {
|
||||
c.logger.Errorf("WriteMessage proto.Marshal err: %v", err)
|
||||
return
|
||||
}
|
||||
m, err := proto.Marshal(&sc_pb.Message{
|
||||
m, err := proto.Marshal(&ss_pb.Message{
|
||||
ID: id,
|
||||
Payload: d,
|
||||
})
|
||||
@@ -29,11 +29,11 @@ func (c *Client) WriteMessage(id sc_pb.MessageID, data proto.Message) {
|
||||
}
|
||||
|
||||
// WriteBytes 向客户端发送字节数据
|
||||
func (c *Client) WriteBytes(id sc_pb.MessageID, data []byte) {
|
||||
func (c *Client) WriteBytes(id ss_pb.MessageID, data []byte) {
|
||||
if c.conn == nil || c.conn.IsClose() {
|
||||
return
|
||||
}
|
||||
m, err := proto.Marshal(&sc_pb.Message{
|
||||
m, err := proto.Marshal(&ss_pb.Message{
|
||||
ID: id,
|
||||
Payload: data,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user