feat 排队

This commit is contained in:
2026-01-06 18:36:17 +08:00
parent 6523820cf6
commit 97c7813a24
9 changed files with 600 additions and 86 deletions

View File

@@ -49,7 +49,22 @@ func (c *Client) Set(ctx context.Context, key string, value interface{}, expirat
return c.cli.Set(ctx, key, value, expiration)
}
// Get 获取数据
func (c *Client) HSet(ctx context.Context, key string, values ...interface{}) *redis.IntCmd {
return c.cli.HSet(ctx, key, values)
}
func (c *Client) Get(ctx context.Context, key string) *redis.StringCmd {
return c.cli.Get(ctx, key)
}
func (c *Client) HGet(ctx context.Context, key, field string) *redis.StringCmd {
return c.cli.HGet(ctx, key, field)
}
func (c *Client) HGetAll(ctx context.Context, key string) *redis.MapStringStringCmd {
return c.cli.HGetAll(ctx, key)
}
func (c *Client) Pipeline() redis.Pipeliner {
return c.cli.Pipeline()
}

View File

@@ -28,9 +28,9 @@ const (
// ISocketServer 由应用层实现
type ISocketServer interface {
OnOpen(ISocketConn) ([]byte, Action) // 开启连接
OnHandShake(ISocketConn, []byte, func(ISocketConn, []byte)) Action // 开始握手
OnMessage(ISocketConn, []byte) Action // 收到消息
OnOpen(ISocketConn) ([]byte, Action) // 开启连接
OnHandShake(ISocketConn) Action // 开始握手
OnMessage(ISocketConn, []byte) Action // 收到消息
OnPong(ISocketConn)
OnClose(ISocketConn, error) Action // 关闭连接
OnTick() (time.Duration, Action)

View File

@@ -103,7 +103,15 @@ func (s *WSServer) OnTraffic(c gnet.Conn) gnet.Action {
data, action := ws.upgrade()
if len(data) > 0 {
s.unUpgradeConn.Delete(c.RemoteAddr().String())
action = gnet.Action(s.i.OnHandShake(ws, data, s.OnHandShakeFinish))
action = gnet.Action(s.i.OnHandShake(ws))
if action == gnet.None {
if err := ws.Conn.AsyncWrite(data, nil); err != nil {
ws.logger.Errorf("OnTraffic upgrade AsyncWrite err: %v", err)
if err = ws.Close(); err != nil {
ws.logger.Errorf("OnTraffic upgrade Close error: %v", err)
}
}
}
}
return action
}
@@ -174,14 +182,3 @@ func (s *WSServer) OnTick() (delay time.Duration, action gnet.Action) {
return
}
// OnHandShakeFinish 握手完成
func (s *WSServer) OnHandShakeFinish(conn socket.ISocketConn, hsResp []byte) {
ws := conn.(*WSConn)
if err := ws.Conn.AsyncWrite(hsResp, nil); err != nil {
ws.logger.Errorf("OnHandShakeFinish err: %v", err)
if err = ws.Close(); err != nil {
ws.logger.Errorf("OnHandShakeFinish Close error: %v", err)
}
}
}

View File

@@ -25,19 +25,22 @@ const (
type ActionID int32
const (
ActionID_ACTION_ID_MOVE ActionID = 0 // 移动
ActionID_ACTION_ID_ATTACK ActionID = 1 // 攻击
ActionID_ACTION_ID_INVALID ActionID = 0
ActionID_ACTION_ID_MOVE ActionID = 1 // 移动
ActionID_ACTION_ID_ATTACK ActionID = 2 // 攻击
)
// Enum value maps for ActionID.
var (
ActionID_name = map[int32]string{
0: "ACTION_ID_MOVE",
1: "ACTION_ID_ATTACK",
0: "ACTION_ID_INVALID",
1: "ACTION_ID_MOVE",
2: "ACTION_ID_ATTACK",
}
ActionID_value = map[string]int32{
"ACTION_ID_MOVE": 0,
"ACTION_ID_ATTACK": 1,
"ACTION_ID_INVALID": 0,
"ACTION_ID_MOVE": 1,
"ACTION_ID_ATTACK": 2,
}
)
@@ -226,7 +229,7 @@ func (x *C2S_Action) GetAction() ActionID {
if x != nil {
return x.Action
}
return ActionID_ACTION_ID_MOVE
return ActionID_ACTION_ID_INVALID
}
func (x *C2S_Action) GetDirX() int32 {
@@ -390,13 +393,14 @@ var file_action_proto_rawDesc = []byte{
0x03, 0x20, 0x01, 0x28, 0x11, 0x52, 0x01, 0x59, 0x22, 0x31, 0x0a, 0x0c, 0x53, 0x32, 0x43, 0x5f,
0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x21, 0x0a, 0x04, 0x49, 0x6e, 0x66, 0x6f,
0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f,
0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x49, 0x6e, 0x66, 0x6f, 0x2a, 0x34, 0x0a, 0x08, 0x41,
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x44, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x43, 0x54, 0x49, 0x4f,
0x4e, 0x5f, 0x49, 0x44, 0x5f, 0x4d, 0x4f, 0x56, 0x45, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x41,
0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x49, 0x44, 0x5f, 0x41, 0x54, 0x54, 0x41, 0x43, 0x4b, 0x10,
0x01, 0x42, 0x17, 0x5a, 0x15, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x2f, 0x73, 0x63, 0x2f, 0x73, 0x63, 0x5f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x49, 0x6e, 0x66, 0x6f, 0x2a, 0x4b, 0x0a, 0x08, 0x41,
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x44, 0x12, 0x15, 0x0a, 0x11, 0x41, 0x43, 0x54, 0x49, 0x4f,
0x4e, 0x5f, 0x49, 0x44, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x10, 0x00, 0x12, 0x12,
0x0a, 0x0e, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x49, 0x44, 0x5f, 0x4d, 0x4f, 0x56, 0x45,
0x10, 0x01, 0x12, 0x14, 0x0a, 0x10, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x49, 0x44, 0x5f,
0x41, 0x54, 0x54, 0x41, 0x43, 0x4b, 0x10, 0x02, 0x42, 0x17, 0x5a, 0x15, 0x63, 0x6f, 0x6d, 0x6d,
0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x63, 0x2f, 0x73, 0x63, 0x5f, 0x70,
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (

View File

@@ -25,24 +25,33 @@ type MessageID int32
const (
MessageID_MESSAGE_ID_INVALID MessageID = 0
MessageID_MESSAGE_ID_ENTER_INSTANCE MessageID = 1 // 进入副本
MessageID_MESSAGE_ID_ACTION MessageID = 2 // 指令
MessageID_MESSAGE_ID_POSITION MessageID = 3 // 位置更新
MessageID_MESSAGE_ID_KICK_OUT MessageID = 1 // 服务器踢人
MessageID_MESSAGE_ID_QUEUE_UP MessageID = 2 // 排队中
MessageID_MESSAGE_ID_LOGIN_SUCCESS MessageID = 3 // 登录成功
MessageID_MESSAGE_ID_ENTER_INSTANCE MessageID = 101 // 进入副本
MessageID_MESSAGE_ID_ACTION MessageID = 102 // 指令
MessageID_MESSAGE_ID_POSITION MessageID = 103 // 位置更新
)
// Enum value maps for MessageID.
var (
MessageID_name = map[int32]string{
0: "MESSAGE_ID_INVALID",
1: "MESSAGE_ID_ENTER_INSTANCE",
2: "MESSAGE_ID_ACTION",
3: "MESSAGE_ID_POSITION",
0: "MESSAGE_ID_INVALID",
1: "MESSAGE_ID_KICK_OUT",
2: "MESSAGE_ID_QUEUE_UP",
3: "MESSAGE_ID_LOGIN_SUCCESS",
101: "MESSAGE_ID_ENTER_INSTANCE",
102: "MESSAGE_ID_ACTION",
103: "MESSAGE_ID_POSITION",
}
MessageID_value = map[string]int32{
"MESSAGE_ID_INVALID": 0,
"MESSAGE_ID_ENTER_INSTANCE": 1,
"MESSAGE_ID_ACTION": 2,
"MESSAGE_ID_POSITION": 3,
"MESSAGE_ID_KICK_OUT": 1,
"MESSAGE_ID_QUEUE_UP": 2,
"MESSAGE_ID_LOGIN_SUCCESS": 3,
"MESSAGE_ID_ENTER_INSTANCE": 101,
"MESSAGE_ID_ACTION": 102,
"MESSAGE_ID_POSITION": 103,
}
)
@@ -137,16 +146,21 @@ var file_define_proto_rawDesc = []byte{
0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
0x49, 0x44, 0x52, 0x02, 0x49, 0x44, 0x12, 0x18, 0x0a, 0x07, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61,
0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64,
0x2a, 0x72, 0x0a, 0x09, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x44, 0x12, 0x16, 0x0a,
0x12, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x5f, 0x49, 0x44, 0x5f, 0x49, 0x4e, 0x56, 0x41,
0x4c, 0x49, 0x44, 0x10, 0x00, 0x12, 0x1d, 0x0a, 0x19, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45,
0x5f, 0x49, 0x44, 0x5f, 0x45, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x4e, 0x53, 0x54, 0x41, 0x4e,
0x43, 0x45, 0x10, 0x01, 0x12, 0x15, 0x0a, 0x11, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x5f,
0x49, 0x44, 0x5f, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x02, 0x12, 0x17, 0x0a, 0x13, 0x4d,
0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x5f, 0x49, 0x44, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49,
0x4f, 0x4e, 0x10, 0x03, 0x42, 0x17, 0x5a, 0x15, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x63, 0x2f, 0x73, 0x63, 0x5f, 0x70, 0x62, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
0x2a, 0xc2, 0x01, 0x0a, 0x09, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x44, 0x12, 0x16,
0x0a, 0x12, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x5f, 0x49, 0x44, 0x5f, 0x49, 0x4e, 0x56,
0x41, 0x4c, 0x49, 0x44, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47,
0x45, 0x5f, 0x49, 0x44, 0x5f, 0x4b, 0x49, 0x43, 0x4b, 0x5f, 0x4f, 0x55, 0x54, 0x10, 0x01, 0x12,
0x17, 0x0a, 0x13, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x5f, 0x49, 0x44, 0x5f, 0x51, 0x55,
0x45, 0x55, 0x45, 0x5f, 0x55, 0x50, 0x10, 0x02, 0x12, 0x1c, 0x0a, 0x18, 0x4d, 0x45, 0x53, 0x53,
0x41, 0x47, 0x45, 0x5f, 0x49, 0x44, 0x5f, 0x4c, 0x4f, 0x47, 0x49, 0x4e, 0x5f, 0x53, 0x55, 0x43,
0x43, 0x45, 0x53, 0x53, 0x10, 0x03, 0x12, 0x1d, 0x0a, 0x19, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47,
0x45, 0x5f, 0x49, 0x44, 0x5f, 0x45, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x4e, 0x53, 0x54, 0x41,
0x4e, 0x43, 0x45, 0x10, 0x65, 0x12, 0x15, 0x0a, 0x11, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45,
0x5f, 0x49, 0x44, 0x5f, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x66, 0x12, 0x17, 0x0a, 0x13,
0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x5f, 0x49, 0x44, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54,
0x49, 0x4f, 0x4e, 0x10, 0x67, 0x42, 0x17, 0x5a, 0x15, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x63, 0x2f, 0x73, 0x63, 0x5f, 0x70, 0x62, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (

View File

@@ -0,0 +1,348 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.32.0
// protoc v4.25.1
// source: service.proto
package sc_pb
import (
_ "common/proto/sc/sc_common"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// MESSAGE_ID_KICK_OUT
type KickOutID int32
const (
KickOutID_KICK_OUT_ID_INVALID KickOutID = 0
KickOutID_KICK_OUT_ID_DUPLICATE_LOGIN KickOutID = 1 // 重复登录
KickOutID_KICK_OUT_ID_SERVER_BUSY KickOutID = 2 // 服务器繁忙
KickOutID_KICK_OUT_ID_SERVER_CLOSE KickOutID = 3 // 服务器关闭
KickOutID_KICK_OUT_ID_QUEUE_UP_FULL KickOutID = 4 // 排队上限
KickOutID_KICK_OUT_ID_TOKEN_INVALID KickOutID = 5 // Token无效
)
// Enum value maps for KickOutID.
var (
KickOutID_name = map[int32]string{
0: "KICK_OUT_ID_INVALID",
1: "KICK_OUT_ID_DUPLICATE_LOGIN",
2: "KICK_OUT_ID_SERVER_BUSY",
3: "KICK_OUT_ID_SERVER_CLOSE",
4: "KICK_OUT_ID_QUEUE_UP_FULL",
5: "KICK_OUT_ID_TOKEN_INVALID",
}
KickOutID_value = map[string]int32{
"KICK_OUT_ID_INVALID": 0,
"KICK_OUT_ID_DUPLICATE_LOGIN": 1,
"KICK_OUT_ID_SERVER_BUSY": 2,
"KICK_OUT_ID_SERVER_CLOSE": 3,
"KICK_OUT_ID_QUEUE_UP_FULL": 4,
"KICK_OUT_ID_TOKEN_INVALID": 5,
}
)
func (x KickOutID) Enum() *KickOutID {
p := new(KickOutID)
*p = x
return p
}
func (x KickOutID) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (KickOutID) Descriptor() protoreflect.EnumDescriptor {
return file_service_proto_enumTypes[0].Descriptor()
}
func (KickOutID) Type() protoreflect.EnumType {
return &file_service_proto_enumTypes[0]
}
func (x KickOutID) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use KickOutID.Descriptor instead.
func (KickOutID) EnumDescriptor() ([]byte, []int) {
return file_service_proto_rawDescGZIP(), []int{0}
}
type S2C_KickOut struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ID KickOutID `protobuf:"varint,1,opt,name=ID,proto3,enum=KickOutID" json:"ID,omitempty"`
}
func (x *S2C_KickOut) Reset() {
*x = S2C_KickOut{}
if protoimpl.UnsafeEnabled {
mi := &file_service_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *S2C_KickOut) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*S2C_KickOut) ProtoMessage() {}
func (x *S2C_KickOut) ProtoReflect() protoreflect.Message {
mi := &file_service_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use S2C_KickOut.ProtoReflect.Descriptor instead.
func (*S2C_KickOut) Descriptor() ([]byte, []int) {
return file_service_proto_rawDescGZIP(), []int{0}
}
func (x *S2C_KickOut) GetID() KickOutID {
if x != nil {
return x.ID
}
return KickOutID_KICK_OUT_ID_INVALID
}
// MESSAGE_ID_QUEUE_UP
type S2C_QueueUp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
QueueUpCount int32 `protobuf:"varint,1,opt,name=QueueUpCount,proto3" json:"QueueUpCount,omitempty"` // 排队人数
}
func (x *S2C_QueueUp) Reset() {
*x = S2C_QueueUp{}
if protoimpl.UnsafeEnabled {
mi := &file_service_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *S2C_QueueUp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*S2C_QueueUp) ProtoMessage() {}
func (x *S2C_QueueUp) ProtoReflect() protoreflect.Message {
mi := &file_service_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use S2C_QueueUp.ProtoReflect.Descriptor instead.
func (*S2C_QueueUp) Descriptor() ([]byte, []int) {
return file_service_proto_rawDescGZIP(), []int{1}
}
func (x *S2C_QueueUp) GetQueueUpCount() int32 {
if x != nil {
return x.QueueUpCount
}
return 0
}
// MESSAGE_ID_LOGIN_SUCCESS
type S2C_LoginSuccess struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
InstanceID int32 `protobuf:"varint,1,opt,name=InstanceID,proto3" json:"InstanceID,omitempty"` // 副本ID
}
func (x *S2C_LoginSuccess) Reset() {
*x = S2C_LoginSuccess{}
if protoimpl.UnsafeEnabled {
mi := &file_service_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *S2C_LoginSuccess) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*S2C_LoginSuccess) ProtoMessage() {}
func (x *S2C_LoginSuccess) ProtoReflect() protoreflect.Message {
mi := &file_service_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use S2C_LoginSuccess.ProtoReflect.Descriptor instead.
func (*S2C_LoginSuccess) Descriptor() ([]byte, []int) {
return file_service_proto_rawDescGZIP(), []int{2}
}
func (x *S2C_LoginSuccess) GetInstanceID() int32 {
if x != nil {
return x.InstanceID
}
return 0
}
var File_service_proto protoreflect.FileDescriptor
var file_service_proto_rawDesc = []byte{
0x0a, 0x0d, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a,
0x0f, 0x73, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x22, 0x29, 0x0a, 0x0b, 0x53, 0x32, 0x43, 0x5f, 0x4b, 0x69, 0x63, 0x6b, 0x4f, 0x75, 0x74, 0x12,
0x1a, 0x0a, 0x02, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x4b, 0x69,
0x63, 0x6b, 0x4f, 0x75, 0x74, 0x49, 0x44, 0x52, 0x02, 0x49, 0x44, 0x22, 0x31, 0x0a, 0x0b, 0x53,
0x32, 0x43, 0x5f, 0x51, 0x75, 0x65, 0x75, 0x65, 0x55, 0x70, 0x12, 0x22, 0x0a, 0x0c, 0x51, 0x75,
0x65, 0x75, 0x65, 0x55, 0x70, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,
0x52, 0x0c, 0x51, 0x75, 0x65, 0x75, 0x65, 0x55, 0x70, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x32,
0x0a, 0x10, 0x53, 0x32, 0x43, 0x5f, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x53, 0x75, 0x63, 0x63, 0x65,
0x73, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x44,
0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65,
0x49, 0x44, 0x2a, 0xbe, 0x01, 0x0a, 0x09, 0x4b, 0x69, 0x63, 0x6b, 0x4f, 0x75, 0x74, 0x49, 0x44,
0x12, 0x17, 0x0a, 0x13, 0x4b, 0x49, 0x43, 0x4b, 0x5f, 0x4f, 0x55, 0x54, 0x5f, 0x49, 0x44, 0x5f,
0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x10, 0x00, 0x12, 0x1f, 0x0a, 0x1b, 0x4b, 0x49, 0x43,
0x4b, 0x5f, 0x4f, 0x55, 0x54, 0x5f, 0x49, 0x44, 0x5f, 0x44, 0x55, 0x50, 0x4c, 0x49, 0x43, 0x41,
0x54, 0x45, 0x5f, 0x4c, 0x4f, 0x47, 0x49, 0x4e, 0x10, 0x01, 0x12, 0x1b, 0x0a, 0x17, 0x4b, 0x49,
0x43, 0x4b, 0x5f, 0x4f, 0x55, 0x54, 0x5f, 0x49, 0x44, 0x5f, 0x53, 0x45, 0x52, 0x56, 0x45, 0x52,
0x5f, 0x42, 0x55, 0x53, 0x59, 0x10, 0x02, 0x12, 0x1c, 0x0a, 0x18, 0x4b, 0x49, 0x43, 0x4b, 0x5f,
0x4f, 0x55, 0x54, 0x5f, 0x49, 0x44, 0x5f, 0x53, 0x45, 0x52, 0x56, 0x45, 0x52, 0x5f, 0x43, 0x4c,
0x4f, 0x53, 0x45, 0x10, 0x03, 0x12, 0x1d, 0x0a, 0x19, 0x4b, 0x49, 0x43, 0x4b, 0x5f, 0x4f, 0x55,
0x54, 0x5f, 0x49, 0x44, 0x5f, 0x51, 0x55, 0x45, 0x55, 0x45, 0x5f, 0x55, 0x50, 0x5f, 0x46, 0x55,
0x4c, 0x4c, 0x10, 0x04, 0x12, 0x1d, 0x0a, 0x19, 0x4b, 0x49, 0x43, 0x4b, 0x5f, 0x4f, 0x55, 0x54,
0x5f, 0x49, 0x44, 0x5f, 0x54, 0x4f, 0x4b, 0x45, 0x4e, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49,
0x44, 0x10, 0x05, 0x42, 0x17, 0x5a, 0x15, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x63, 0x2f, 0x73, 0x63, 0x5f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
}
var (
file_service_proto_rawDescOnce sync.Once
file_service_proto_rawDescData = file_service_proto_rawDesc
)
func file_service_proto_rawDescGZIP() []byte {
file_service_proto_rawDescOnce.Do(func() {
file_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_service_proto_rawDescData)
})
return file_service_proto_rawDescData
}
var file_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_service_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_service_proto_goTypes = []interface{}{
(KickOutID)(0), // 0: KickOutID
(*S2C_KickOut)(nil), // 1: S2C_KickOut
(*S2C_QueueUp)(nil), // 2: S2C_QueueUp
(*S2C_LoginSuccess)(nil), // 3: S2C_LoginSuccess
}
var file_service_proto_depIdxs = []int32{
0, // 0: S2C_KickOut.ID:type_name -> KickOutID
1, // [1:1] is the sub-list for method output_type
1, // [1:1] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_service_proto_init() }
func file_service_proto_init() {
if File_service_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*S2C_KickOut); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*S2C_QueueUp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*S2C_LoginSuccess); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_service_proto_rawDesc,
NumEnums: 1,
NumMessages: 3,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_service_proto_goTypes,
DependencyIndexes: file_service_proto_depIdxs,
EnumInfos: file_service_proto_enumTypes,
MessageInfos: file_service_proto_msgTypes,
}.Build()
File_service_proto = out.File
file_service_proto_rawDesc = nil
file_service_proto_goTypes = nil
file_service_proto_depIdxs = nil
}

View File

@@ -122,6 +122,91 @@ func (*ToClientResp) Descriptor() ([]byte, []int) {
return file_service_gateway_proto_rawDescGZIP(), []int{1}
}
type KickUserReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN int64 `protobuf:"varint,1,opt,name=USN,proto3" json:"USN,omitempty"`
}
func (x *KickUserReq) Reset() {
*x = KickUserReq{}
if protoimpl.UnsafeEnabled {
mi := &file_service_gateway_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *KickUserReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*KickUserReq) ProtoMessage() {}
func (x *KickUserReq) ProtoReflect() protoreflect.Message {
mi := &file_service_gateway_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use KickUserReq.ProtoReflect.Descriptor instead.
func (*KickUserReq) Descriptor() ([]byte, []int) {
return file_service_gateway_proto_rawDescGZIP(), []int{2}
}
func (x *KickUserReq) GetUSN() int64 {
if x != nil {
return x.USN
}
return 0
}
type KickUserResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *KickUserResp) Reset() {
*x = KickUserResp{}
if protoimpl.UnsafeEnabled {
mi := &file_service_gateway_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *KickUserResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*KickUserResp) ProtoMessage() {}
func (x *KickUserResp) ProtoReflect() protoreflect.Message {
mi := &file_service_gateway_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use KickUserResp.ProtoReflect.Descriptor instead.
func (*KickUserResp) Descriptor() ([]byte, []int) {
return file_service_gateway_proto_rawDescGZIP(), []int{3}
}
var File_service_gateway_proto protoreflect.FileDescriptor
var file_service_gateway_proto_rawDesc = []byte{
@@ -134,12 +219,18 @@ var file_service_gateway_proto_rawDesc = []byte{
0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x44, 0x12, 0x18, 0x0a, 0x07, 0x50, 0x61, 0x79, 0x6c, 0x6f,
0x61, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61,
0x64, 0x22, 0x0e, 0x0a, 0x0c, 0x54, 0x6f, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73,
0x70, 0x32, 0x36, 0x0a, 0x07, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x12, 0x2b, 0x0a, 0x08,
0x54, 0x6f, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x0c, 0x2e, 0x54, 0x6f, 0x43, 0x6c, 0x69,
0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x0d, 0x2e, 0x54, 0x6f, 0x43, 0x6c, 0x69, 0x65, 0x6e,
0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x28, 0x01, 0x42, 0x19, 0x5a, 0x17, 0x63, 0x6f, 0x6d,
0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x73, 0x2f, 0x67, 0x72, 0x70,
0x63, 0x5f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x70, 0x22, 0x1f, 0x0a, 0x0b, 0x4b, 0x69, 0x63, 0x6b, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71,
0x12, 0x10, 0x0a, 0x03, 0x55, 0x53, 0x4e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x55,
0x53, 0x4e, 0x22, 0x0e, 0x0a, 0x0c, 0x4b, 0x69, 0x63, 0x6b, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65,
0x73, 0x70, 0x32, 0x61, 0x0a, 0x07, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x12, 0x2b, 0x0a,
0x08, 0x54, 0x6f, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x0c, 0x2e, 0x54, 0x6f, 0x43, 0x6c,
0x69, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x0d, 0x2e, 0x54, 0x6f, 0x43, 0x6c, 0x69, 0x65,
0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x28, 0x01, 0x12, 0x29, 0x0a, 0x08, 0x4b, 0x69,
0x63, 0x6b, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0c, 0x2e, 0x4b, 0x69, 0x63, 0x6b, 0x55, 0x73, 0x65,
0x72, 0x52, 0x65, 0x71, 0x1a, 0x0d, 0x2e, 0x4b, 0x69, 0x63, 0x6b, 0x55, 0x73, 0x65, 0x72, 0x52,
0x65, 0x73, 0x70, 0x22, 0x00, 0x42, 0x19, 0x5a, 0x17, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x73, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x70, 0x62,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -154,16 +245,20 @@ func file_service_gateway_proto_rawDescGZIP() []byte {
return file_service_gateway_proto_rawDescData
}
var file_service_gateway_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_service_gateway_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_service_gateway_proto_goTypes = []interface{}{
(*ToClientReq)(nil), // 0: ToClientReq
(*ToClientResp)(nil), // 1: ToClientResp
(*KickUserReq)(nil), // 2: KickUserReq
(*KickUserResp)(nil), // 3: KickUserResp
}
var file_service_gateway_proto_depIdxs = []int32{
0, // 0: Gateway.ToClient:input_type -> ToClientReq
1, // 1: Gateway.ToClient:output_type -> ToClientResp
1, // [1:2] is the sub-list for method output_type
0, // [0:1] is the sub-list for method input_type
2, // 1: Gateway.KickUser:input_type -> KickUserReq
1, // 2: Gateway.ToClient:output_type -> ToClientResp
3, // 3: Gateway.KickUser:output_type -> KickUserResp
2, // [2:4] is the sub-list for method output_type
0, // [0:2] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
@@ -199,6 +294,30 @@ func file_service_gateway_proto_init() {
return nil
}
}
file_service_gateway_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*KickUserReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_gateway_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*KickUserResp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
@@ -206,7 +325,7 @@ func file_service_gateway_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_service_gateway_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumMessages: 4,
NumExtensions: 0,
NumServices: 1,
},

View File

@@ -24,6 +24,7 @@ const _ = grpc.SupportPackageIsVersion7
type GatewayClient interface {
// 发送消息到客户端
ToClient(ctx context.Context, opts ...grpc.CallOption) (Gateway_ToClientClient, error)
KickUser(ctx context.Context, in *KickUserReq, opts ...grpc.CallOption) (*KickUserResp, error)
}
type gatewayClient struct {
@@ -68,12 +69,22 @@ func (x *gatewayToClientClient) CloseAndRecv() (*ToClientResp, error) {
return m, nil
}
func (c *gatewayClient) KickUser(ctx context.Context, in *KickUserReq, opts ...grpc.CallOption) (*KickUserResp, error) {
out := new(KickUserResp)
err := c.cc.Invoke(ctx, "/Gateway/KickUser", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// GatewayServer is the server API for Gateway service.
// All implementations must embed UnimplementedGatewayServer
// for forward compatibility
type GatewayServer interface {
// 发送消息到客户端
ToClient(Gateway_ToClientServer) error
KickUser(context.Context, *KickUserReq) (*KickUserResp, error)
mustEmbedUnimplementedGatewayServer()
}
@@ -84,6 +95,9 @@ type UnimplementedGatewayServer struct {
func (UnimplementedGatewayServer) ToClient(Gateway_ToClientServer) error {
return status.Errorf(codes.Unimplemented, "method ToClient not implemented")
}
func (UnimplementedGatewayServer) KickUser(context.Context, *KickUserReq) (*KickUserResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method KickUser not implemented")
}
func (UnimplementedGatewayServer) mustEmbedUnimplementedGatewayServer() {}
// UnsafeGatewayServer may be embedded to opt out of forward compatibility for this service.
@@ -123,13 +137,36 @@ func (x *gatewayToClientServer) Recv() (*ToClientReq, error) {
return m, nil
}
func _Gateway_KickUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(KickUserReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GatewayServer).KickUser(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Gateway/KickUser",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GatewayServer).KickUser(ctx, req.(*KickUserReq))
}
return interceptor(ctx, in, info, handler)
}
// Gateway_ServiceDesc is the grpc.ServiceDesc for Gateway service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Gateway_ServiceDesc = grpc.ServiceDesc{
ServiceName: "Gateway",
HandlerType: (*GatewayServer)(nil),
Methods: []grpc.MethodDesc{},
Methods: []grpc.MethodDesc{
{
MethodName: "KickUser",
Handler: _Gateway_KickUser_Handler,
},
},
Streams: []grpc.StreamDesc{
{
StreamName: "ToClient",

View File

@@ -160,10 +160,8 @@ type LeaveReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN int64 `protobuf:"varint,1,opt,name=USN,proto3" json:"USN,omitempty"` // 用户ID
GatewaySID int64 `protobuf:"varint,2,opt,name=GatewaySID,proto3" json:"GatewaySID,omitempty"` // 网关服务ID
InstanceID int32 `protobuf:"varint,3,opt,name=InstanceID,proto3" json:"InstanceID,omitempty"` // 副本ID
UniqueNo int64 `protobuf:"varint,4,opt,name=UniqueNo,proto3" json:"UniqueNo,omitempty"` // 副本唯一编号
USN int64 `protobuf:"varint,1,opt,name=USN,proto3" json:"USN,omitempty"` // 用户ID
UniqueNo int64 `protobuf:"varint,2,opt,name=UniqueNo,proto3" json:"UniqueNo,omitempty"` // 副本唯一编号
}
func (x *LeaveReq) Reset() {
@@ -205,20 +203,6 @@ func (x *LeaveReq) GetUSN() int64 {
return 0
}
func (x *LeaveReq) GetGatewaySID() int64 {
if x != nil {
return x.GatewaySID
}
return 0
}
func (x *LeaveReq) GetInstanceID() int32 {
if x != nil {
return x.InstanceID
}
return 0
}
func (x *LeaveReq) GetUniqueNo() int64 {
if x != nil {
return x.UniqueNo
@@ -408,13 +392,9 @@ var file_service_scene_proto_rawDesc = []byte{
0x73, 0x61, 0x67, 0x65, 0x49, 0x44, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x4d, 0x65,
0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x44, 0x12, 0x18, 0x0a, 0x07, 0x50, 0x61, 0x79, 0x6c, 0x6f,
0x61, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61,
0x64, 0x22, 0x78, 0x0a, 0x08, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a,
0x64, 0x22, 0x38, 0x0a, 0x08, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a,
0x03, 0x55, 0x53, 0x4e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x55, 0x53, 0x4e, 0x12,
0x1e, 0x0a, 0x0a, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x49, 0x44, 0x18, 0x02, 0x20,
0x01, 0x28, 0x03, 0x52, 0x0a, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x49, 0x44, 0x12,
0x1e, 0x0a, 0x0a, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x44, 0x18, 0x03, 0x20,
0x01, 0x28, 0x05, 0x52, 0x0a, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x44, 0x12,
0x1a, 0x0a, 0x08, 0x55, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x4e, 0x6f, 0x18, 0x04, 0x20, 0x01, 0x28,
0x1a, 0x0a, 0x08, 0x55, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x4e, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28,
0x03, 0x52, 0x08, 0x55, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x4e, 0x6f, 0x22, 0x0b, 0x0a, 0x09, 0x4c,
0x65, 0x61, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x22, 0x93, 0x01, 0x0a, 0x09, 0x41, 0x63, 0x74,
0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x55, 0x6e, 0x69, 0x71, 0x75, 0x65,