feat sc改名ss

This commit is contained in:
2026-01-12 12:20:10 +08:00
parent 9ff7402d40
commit a2ca234358
5 changed files with 23 additions and 21 deletions

View File

@@ -8,7 +8,7 @@ import (
"errors"
"fmt"
"git.hlsq.asia/mmorpg/service-common/log"
"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-common/utils"
"github.com/gorilla/websocket"
"google.golang.org/protobuf/proto"
@@ -100,7 +100,7 @@ func (c *Client) startReader() {
return
}
msg := &sc_pb.Message{}
msg := &ss_pb.Message{}
if err = proto.Unmarshal(msgByte, msg); err != nil {
continue
}
@@ -132,12 +132,12 @@ func (c *Client) startWriter() {
}
// WriteMessage 发送消息给服务器
func (c *Client) WriteMessage(msgID sc_pb.MessageID, data proto.Message) error {
func (c *Client) WriteMessage(msgID ss_pb.MessageID, data proto.Message) error {
d, err := proto.Marshal(data)
if err != nil {
return err
}
p := &sc_pb.Message{
p := &ss_pb.Message{
ID: msgID,
Payload: d,
}

View File

@@ -2,7 +2,7 @@ package ws
import (
"git.hlsq.asia/mmorpg/service-common/log"
"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"
"math"
"math/rand"
@@ -14,14 +14,14 @@ type LoginSuccess struct {
}
func (_ *LoginSuccess) Handle(data []byte, client *Client) {
msg := &sc_pb.S2C_LoginSuccess{}
msg := &ss_pb.S2C_LoginSuccess{}
if err := proto.Unmarshal(data, msg); err != nil {
log.Errorf("handle msg error")
client.Stop()
return
}
_ = client.WriteMessage(sc_pb.MessageID_MESSAGE_ID_ENTER_INSTANCE, &sc_pb.C2S_EnterInstance{
_ = client.WriteMessage(ss_pb.MessageID_MESSAGE_ID_ENTER_INSTANCE, &ss_pb.C2S_EnterInstance{
InstanceID: msg.InstanceID,
})
}
@@ -30,7 +30,7 @@ type QueueUp struct {
}
func (_ *QueueUp) Handle(data []byte, client *Client) {
msg := &sc_pb.S2C_QueueUp{}
msg := &ss_pb.S2C_QueueUp{}
if err := proto.Unmarshal(data, msg); err != nil {
log.Errorf("handle msg error")
client.Stop()
@@ -42,7 +42,7 @@ type EnterInstance struct {
}
func (_ *EnterInstance) Handle(data []byte, client *Client) {
msg := &sc_pb.S2C_EnterInstance{}
msg := &ss_pb.S2C_EnterInstance{}
if err := proto.Unmarshal(data, msg); err != nil {
log.Errorf("handle msg error")
client.Stop()
@@ -65,10 +65,10 @@ func (_ *EnterInstance) Handle(data []byte, client *Client) {
go func() {
for {
x, y := randDir()
_ = client.WriteMessage(sc_pb.MessageID_MESSAGE_ID_ACTION, &sc_pb.C2S_Action{
_ = client.WriteMessage(ss_pb.MessageID_MESSAGE_ID_ACTION, &ss_pb.C2S_Action{
Sequence: 0,
Timestamp: 0,
Action: sc_pb.ActionID_ACTION_ID_MOVE,
Action: ss_pb.ActionID_ACTION_ID_MOVE,
DirX: int32(x * 100),
DirY: int32(y * 100),
SkillID: 0,
@@ -80,7 +80,7 @@ func (_ *EnterInstance) Handle(data []byte, client *Client) {
var s2cPositionPool = sync.Pool{
New: func() interface{} {
return &sc_pb.Message{}
return &ss_pb.Message{}
},
}
@@ -88,7 +88,7 @@ type Position struct {
}
func (_ *Position) Handle(data []byte, client *Client) {
//msg := s2cPositionPool.Get().(*sc_pb.Message)
//msg := s2cPositionPool.Get().(*ss_pb.Message)
//if err := proto.Unmarshal(data, msg); err != nil {
// log.Errorf("handle msg error")
// client.Stop()

View File

@@ -1,17 +1,17 @@
package ws
import "git.hlsq.asia/mmorpg/service-common/proto/sc/sc_pb"
import "git.hlsq.asia/mmorpg/service-common/proto/ss/ss_pb"
var router map[sc_pb.MessageID]BaseRouter
var router map[ss_pb.MessageID]BaseRouter
type BaseRouter interface {
Handle(data []byte, client *Client)
}
func init() {
router = make(map[sc_pb.MessageID]BaseRouter)
router[sc_pb.MessageID_MESSAGE_ID_LOGIN_SUCCESS] = &LoginSuccess{}
router[sc_pb.MessageID_MESSAGE_ID_QUEUE_UP] = &QueueUp{}
router[sc_pb.MessageID_MESSAGE_ID_ENTER_INSTANCE] = &EnterInstance{}
router[sc_pb.MessageID_MESSAGE_ID_POSITION] = &Position{}
router = make(map[ss_pb.MessageID]BaseRouter)
router[ss_pb.MessageID_MESSAGE_ID_LOGIN_SUCCESS] = &LoginSuccess{}
router[ss_pb.MessageID_MESSAGE_ID_QUEUE_UP] = &QueueUp{}
router[ss_pb.MessageID_MESSAGE_ID_ENTER_INSTANCE] = &EnterInstance{}
router[ss_pb.MessageID_MESSAGE_ID_POSITION] = &Position{}
}