color game

This commit is contained in:
liuxiaobo 2025-06-07 01:58:14 +08:00
parent 8cc514ecf7
commit e699a325a0
23 changed files with 625 additions and 539 deletions

View File

@ -4,38 +4,33 @@ import (
"fmt"
"game/common/proto/pb"
"github.com/fox/fox/log"
"github.com/fox/fox/timer"
"github.com/golang/protobuf/proto"
"time"
)
type LastMsg struct {
Msg interface{}
MsgId string
Tm time.Time
}
type BaseRoom[Seat ISeat] struct {
id int
roomType int // 房间配置id 初级,中级,高级
playType int // 玩法配置id color玩法id
gameNo string
Seats []Seat
timeTypes map[TimerType]uint32
timerHandler ITimerHandler
id int
roomType int // 房间配置id 初级,中级,高级
playType int // 玩法配置id color玩法id
gameNo string
Seats []Seat
timeTypes map[TimerType]uint32
truthRoom IRoom
sTimer timer.ITimer
sender ISender
subRoom IRoom
sTimer ITimer
sender ISender
}
func NewBaseRoom[Seat ISeat](id, roomType, playType int) (*BaseRoom[Seat], pb.ErrCode) {
func NewBaseRoom[Seat ISeat](id, roomType, playType int, subRoom IRoom, sTimer ITimer, sender ISender) (*BaseRoom[Seat], pb.ErrCode) {
room := &BaseRoom[Seat]{
id: id,
roomType: roomType,
playType: playType,
gameNo: "",
timeTypes: make(map[TimerType]uint32),
subRoom: subRoom,
sTimer: sTimer,
sender: sender,
}
return room, pb.ErrCode_OK
@ -50,7 +45,7 @@ func (r *BaseRoom[Seat]) RoomType() int {
}
func (r *BaseRoom[Seat]) SetTruthRoom(rm IRoom) {
r.truthRoom = rm
r.subRoom = rm
}
func (r *BaseRoom[Seat]) PlayType() int {
@ -99,16 +94,6 @@ func (r *BaseRoom[Seat]) HasEmptySeat() bool {
return false
}
// IsPlayerCurrentRoom 多个房间都有该玩家时,判断该房间是不是这个玩家的当前房间
func (r *BaseRoom[Seat]) IsPlayerCurrentRoom(uid int64) bool {
for _, seat := range r.Seats {
if !seat.Empty() && seat.Player().Id() == uid {
return true
}
}
return false
}
func (r *BaseRoom[Seat]) HasPlayer(uid int64) bool {
for _, seat := range r.Seats {
if !seat.Empty() && seat.Player().Id() == uid {
@ -118,12 +103,6 @@ func (r *BaseRoom[Seat]) HasPlayer(uid int64) bool {
return false
}
func (r *BaseRoom[Seat]) SetTimerHandler(th ITimerHandler) {
if r.timerHandler == nil {
r.timerHandler = th
}
}
func (r *BaseRoom[Seat]) AddPlayer(player IPlayer, seat int) {
if seat < 0 || seat >= len(r.Seats) {
log.Error(r.SeatLog(r.Seats[seat], "out of range"))
@ -142,7 +121,13 @@ func (r *BaseRoom[Seat]) RemovePlayer(player IPlayer) {
}
}
func (r *BaseRoom[Seat]) OnMessage(_ string, _ map[string]interface{}) {}
func (r *BaseRoom[Seat]) OnMessage(cmd int32, params ...any) {
if r.subRoom == nil {
log.Error(r.Log("sub room is nil"))
return
}
r.subRoom.OnMessage(cmd, params...)
}
func (r *BaseRoom[Seat]) DebugSendMsg(user IPlayer, msgId pb.MsgId, msg proto.Message) {
log.Debug(r.UserLog(user.Id(), "send msg:%v %v", msgId, msg.String()))
@ -181,7 +166,7 @@ func (r *BaseRoom[Seat]) Broadcast(msgId pb.MsgId, msg proto.Message, exclude ..
}
func (r *BaseRoom[Seat]) NewTimer(timerType TimerType, duration time.Duration, args ...interface{}) {
if r.timerHandler == nil {
if r.sTimer == nil {
log.Error(r.Log("timer handler is nil"))
return
}
@ -193,7 +178,7 @@ func (r *BaseRoom[Seat]) NewTimer(timerType TimerType, duration time.Duration, a
return
}
tid := r.sTimer.NewTimer(duration+time.Duration(10)*time.Millisecond, func() {
r.timerHandler.OnTimer(timerType, args...)
r.sTimer.OnTimer(timerType, args...)
}, true, r.Log("start type:%v timer", timerType.String()))
r.timeTypes[timerType] = tid
// log.Debug(r.Log("start type:%v timer", timerType.String()))

View File

@ -1,26 +1,39 @@
package baseroom
import (
"time"
type SeatStatus int
const (
SsWaitStart SeatStatus = 0 // 等待开始
SsReadyStart SeatStatus = 1 // 准备
SsPlaying SeatStatus = 2 // 游戏中
SsFakeLeave SeatStatus = 3 // 假离开
)
func (t SeatStatus) String() string {
switch t {
case SsWaitStart:
return "wait-start"
case SsReadyStart:
return "ready-start"
case SsPlaying:
return "playing"
case SsFakeLeave:
return "fake-leave"
}
return "not-exist-seat-status"
}
type BaseSeat struct {
no int
player IPlayer
fakeLeave bool
isCurrent bool // 多开时该标记true为玩家的当前桌
canAct bool // true:当前能叫分或出牌
ready bool
seatedTime time.Time // 落座的时间
no int
player IPlayer
status SeatStatus
}
func NewBaseSeat(no int) *BaseSeat {
return &BaseSeat{no: no}
}
// SeatedTime 落座时间
func (s *BaseSeat) SeatedTime() time.Time {
return s.seatedTime
return &BaseSeat{
no: no,
status: SsWaitStart,
}
}
func (s *BaseSeat) No() int {
@ -37,41 +50,12 @@ func (s *BaseSeat) Player() IPlayer {
func (s *BaseSeat) SetPlayer(player IPlayer) {
s.player = player
if player != nil {
s.seatedTime = time.Now()
} else {
s.seatedTime = time.Time{}
}
}
func (s *BaseSeat) FakeLeave() bool {
return s.fakeLeave
func (s *BaseSeat) Status() SeatStatus {
return s.status
}
func (s *BaseSeat) SetFakeLeave(fakeLeave bool) {
s.fakeLeave = fakeLeave
}
func (s *BaseSeat) SetCurrentRoom(flag bool) {
s.isCurrent = flag
}
func (s *BaseSeat) IsPlayerCurrentRoom() bool {
return s.isCurrent
}
func (s *BaseSeat) CanAct() bool {
return s.canAct
}
func (s *BaseSeat) SetCanAct(can bool) {
s.canAct = can
}
func (s *BaseSeat) Ready() bool {
return s.ready
}
func (s *BaseSeat) SetReady(ready bool) {
s.ready = ready
func (s *BaseSeat) SetStatus(status SeatStatus) {
s.status = status
}

View File

@ -1,6 +1,10 @@
package baseroom
import "game/common/proto/pb"
import (
"game/common/proto/pb"
"github.com/golang/protobuf/proto"
"time"
)
type IRoom interface {
Id() int
@ -18,9 +22,8 @@ type ISeat interface {
Empty() bool
Player() IPlayer
SetPlayer(player IPlayer)
FakeLeave() bool
SetFakeLeave(leave bool)
// SeatedTime() time.Time
Status() SeatStatus
SetStatus(status SeatStatus)
}
type IPlayer interface {
@ -32,14 +35,20 @@ type IRobot interface {
OnMessage(cmd pb.MsgId, params ...any)
}
type ITimerHandler interface {
type ITimer interface {
OnTimer(timerType TimerType, args ...interface{})
NewTimer(duration time.Duration, cb func(), needLog bool, desc ...string) uint32
CancelTimer(timerId uint32)
}
type ISender interface {
SendMsg(user IPlayer, msgId pb.MsgId, msg interface{})
SendMsg(user IPlayer, msgId pb.MsgId, msg proto.Message)
}
type ICreateRoom interface {
CreateRoom(id, roomType int) (IRoom, pb.ErrCode)
}
type ICreatePlayer interface {
CreatePlayer(id int64) (IPlayer, pb.ErrCode)
}

View File

@ -0,0 +1,51 @@
package baseroom
import (
"game/common/proto/pb"
)
type PlayerMgr struct {
players map[int64]IPlayer
createPlayer ICreatePlayer
}
func NewPlayerMgr(create ICreatePlayer) *PlayerMgr {
return &PlayerMgr{
players: make(map[int64]IPlayer),
createPlayer: create,
}
}
func (s *PlayerMgr) Count() int {
return len(s.players)
}
func (s *PlayerMgr) Init() {
}
func (s *PlayerMgr) Add(player IPlayer) {
s.players[player.Id()] = player
}
func (s *PlayerMgr) Del(uid int64) {
delete(s.players, uid)
}
func (s *PlayerMgr) Find(uid int64) IPlayer {
return s.players[uid]
}
func (s *PlayerMgr) Filter(predicate func(player IPlayer) bool) []IPlayer {
players := make([]IPlayer, 0)
for _, player := range s.players {
if predicate(player) {
players = append(players, player)
}
}
return players
}
func (s *PlayerMgr) CreatePlayer(uid int64) (player IPlayer, code pb.ErrCode) {
player, code = s.createPlayer.CreatePlayer(uid)
return
}

View File

@ -43,10 +43,6 @@ func (s *RoomMgr) Del(id int) {
delete(s.rooms, id)
}
func (s *RoomMgr) Len() int {
return len(s.rooms)
}
func (s *RoomMgr) Find(id int) IRoom {
return s.rooms[id]
}

View File

@ -39,16 +39,18 @@ func LoadSpecialConfig[T any](rd *redis.Client, specialKey string, comm *Common[
if s == "" {
return fmt.Errorf("config:%s not found from redis", specialKey)
}
if err = json.Unmarshal([]byte(s), comm.Special); err != nil {
log.FatalF("init special config:%v", err)
var result resultT[T]
if err = json.Unmarshal([]byte(s), &result.Value); err != nil {
log.ErrorF("init special config:%v", err)
return err
}
comm.Special = &result.Value
return nil
}
type resultT[T any] struct {
Value T
Err error
//Err error
}
func LoadCommonConfig[T any](rd *redis.Client, GitCommit, GitBranch, BuildDate string) (*Common[T], error) {

View File

@ -9,6 +9,8 @@ enum ServiceTypeId
STI_Login = 101; //
STI_Chat = 102; //
STI_DB = 103; // db服
STI_ColorGame = 120; // color game
}

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.34.1
// protoc v4.25.2
// protoc-gen-go v1.36.6
// protoc v6.31.0
// source: chat.proto
package pb
@ -11,6 +11,7 @@ import (
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
@ -75,24 +76,21 @@ func (ChatType) EnumDescriptor() ([]byte, []int) {
// 聊天消息
type C2SChat struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
SrcUser *ChatUser `protobuf:"bytes,1,opt,name=src_user,json=srcUser,proto3" json:"src_user,omitempty"` // 说话的人
DstUser *ChatUser `protobuf:"bytes,2,opt,name=dst_user,json=dstUser,proto3" json:"dst_user,omitempty"` // 接收者
Type ChatType `protobuf:"varint,3,opt,name=type,proto3,enum=pb.ChatType" json:"type,omitempty"` // 聊天类型
GameId ServiceTypeId `protobuf:"varint,4,opt,name=game_id,json=gameId,proto3,enum=pb.ServiceTypeId" json:"game_id,omitempty"` // 游戏id只在本玩法中显示的聊天信息
Content string `protobuf:"bytes,5,opt,name=content,proto3" json:"content,omitempty"` // 内容
unknownFields protoimpl.UnknownFields
SrcUser *ChatUser `protobuf:"bytes,1,opt,name=src_user,json=srcUser,proto3" json:"src_user,omitempty"` // 说话的人
DstUser *ChatUser `protobuf:"bytes,2,opt,name=dst_user,json=dstUser,proto3" json:"dst_user,omitempty"` // 接收者
Type ChatType `protobuf:"varint,3,opt,name=type,proto3,enum=pb.ChatType" json:"type,omitempty"` // 聊天类型
GameId ServiceTypeId `protobuf:"varint,4,opt,name=game_id,json=gameId,proto3,enum=pb.ServiceTypeId" json:"game_id,omitempty"` // 游戏id只在本玩法中显示的聊天信息
Content string `protobuf:"bytes,5,opt,name=content,proto3" json:"content,omitempty"` // 内容
sizeCache protoimpl.SizeCache
}
func (x *C2SChat) Reset() {
*x = C2SChat{}
if protoimpl.UnsafeEnabled {
mi := &file_chat_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_chat_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *C2SChat) String() string {
@ -103,7 +101,7 @@ func (*C2SChat) ProtoMessage() {}
func (x *C2SChat) ProtoReflect() protoreflect.Message {
mi := &file_chat_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -155,46 +153,41 @@ func (x *C2SChat) GetContent() string {
var File_chat_proto protoreflect.FileDescriptor
var file_chat_proto_rawDesc = []byte{
0x0a, 0x0a, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62,
0x1a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0d, 0x73, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc3, 0x01, 0x0a, 0x07,
0x43, 0x32, 0x53, 0x43, 0x68, 0x61, 0x74, 0x12, 0x27, 0x0a, 0x08, 0x73, 0x72, 0x63, 0x5f, 0x75,
0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x62, 0x2e, 0x43,
0x68, 0x61, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x07, 0x73, 0x72, 0x63, 0x55, 0x73, 0x65, 0x72,
0x12, 0x27, 0x0a, 0x08, 0x64, 0x73, 0x74, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x68, 0x61, 0x74, 0x55, 0x73, 0x65, 0x72,
0x52, 0x07, 0x64, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x20, 0x0a, 0x04, 0x74, 0x79, 0x70,
0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0c, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x68, 0x61,
0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x2a, 0x0a, 0x07, 0x67,
0x61, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e, 0x70,
0x62, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x49, 0x64, 0x52,
0x06, 0x67, 0x61, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65,
0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e,
0x74, 0x2a, 0x48, 0x0a, 0x08, 0x43, 0x68, 0x61, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0e, 0x0a,
0x0a, 0x43, 0x54, 0x5f, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0e, 0x0a,
0x0a, 0x43, 0x54, 0x5f, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x10, 0x01, 0x12, 0x0c, 0x0a,
0x08, 0x43, 0x54, 0x5f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x43,
0x54, 0x5f, 0x4d, 0x61, 0x72, 0x71, 0x75, 0x65, 0x65, 0x10, 0x03, 0x42, 0x11, 0x5a, 0x0f, 0x63,
0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x62, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
const file_chat_proto_rawDesc = "" +
"\n" +
"\n" +
"chat.proto\x12\x02pb\x1a\n" +
"user.proto\x1a\rservice.proto\"\xc3\x01\n" +
"\aC2SChat\x12'\n" +
"\bsrc_user\x18\x01 \x01(\v2\f.pb.ChatUserR\asrcUser\x12'\n" +
"\bdst_user\x18\x02 \x01(\v2\f.pb.ChatUserR\adstUser\x12 \n" +
"\x04type\x18\x03 \x01(\x0e2\f.pb.ChatTypeR\x04type\x12*\n" +
"\agame_id\x18\x04 \x01(\x0e2\x11.pb.ServiceTypeIdR\x06gameId\x12\x18\n" +
"\acontent\x18\x05 \x01(\tR\acontent*H\n" +
"\bChatType\x12\x0e\n" +
"\n" +
"CT_Unknown\x10\x00\x12\x0e\n" +
"\n" +
"CT_Private\x10\x01\x12\f\n" +
"\bCT_World\x10\x02\x12\x0e\n" +
"\n" +
"CT_Marquee\x10\x03B\x11Z\x0fcommon/proto/pbb\x06proto3"
var (
file_chat_proto_rawDescOnce sync.Once
file_chat_proto_rawDescData = file_chat_proto_rawDesc
file_chat_proto_rawDescData []byte
)
func file_chat_proto_rawDescGZIP() []byte {
file_chat_proto_rawDescOnce.Do(func() {
file_chat_proto_rawDescData = protoimpl.X.CompressGZIP(file_chat_proto_rawDescData)
file_chat_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_chat_proto_rawDesc), len(file_chat_proto_rawDesc)))
})
return file_chat_proto_rawDescData
}
var file_chat_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_chat_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_chat_proto_goTypes = []interface{}{
var file_chat_proto_goTypes = []any{
(ChatType)(0), // 0: pb.ChatType
(*C2SChat)(nil), // 1: pb.C2SChat
(*ChatUser)(nil), // 2: pb.ChatUser
@ -219,25 +212,11 @@ func file_chat_proto_init() {
}
file_user_proto_init()
file_service_proto_init()
if !protoimpl.UnsafeEnabled {
file_chat_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*C2SChat); 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_chat_proto_rawDesc,
RawDescriptor: unsafe.Slice(unsafe.StringData(file_chat_proto_rawDesc), len(file_chat_proto_rawDesc)),
NumEnums: 1,
NumMessages: 1,
NumExtensions: 0,
@ -249,7 +228,6 @@ func file_chat_proto_init() {
MessageInfos: file_chat_proto_msgTypes,
}.Build()
File_chat_proto = out.File
file_chat_proto_rawDesc = nil
file_chat_proto_goTypes = nil
file_chat_proto_depIdxs = nil
}

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.34.1
// protoc v4.25.2
// protoc-gen-go v1.36.6
// protoc v6.31.0
// source: client.proto
package pb
@ -11,6 +11,7 @@ import (
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
@ -21,24 +22,21 @@ const (
)
type ClientMsg struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
ServiceTid ServiceTypeId `protobuf:"varint,1,opt,name=service_tid,json=serviceTid,proto3,enum=pb.ServiceTypeId" json:"service_tid,omitempty"` // 服务id
ServiceName string `protobuf:"bytes,2,opt,name=service_name,json=serviceName,proto3" json:"service_name,omitempty"` // 具体的服务节点名(客户端进入新的场景,保存该节点名,提高路由速度)
UserId int64 `protobuf:"varint,3,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // 玩家id
MsgId int32 `protobuf:"varint,4,opt,name=msg_id,json=msgId,proto3" json:"msg_id,omitempty"` // 消息id
Data []byte `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"` // 消息体
unknownFields protoimpl.UnknownFields
ServiceTid ServiceTypeId `protobuf:"varint,1,opt,name=service_tid,json=serviceTid,proto3,enum=pb.ServiceTypeId" json:"service_tid,omitempty"` // 服务id
ServiceName string `protobuf:"bytes,2,opt,name=service_name,json=serviceName,proto3" json:"service_name,omitempty"` // 具体的服务节点名(客户端进入新的场景,保存该节点名,提高路由速度)
UserId int64 `protobuf:"varint,3,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // 玩家id
MsgId int32 `protobuf:"varint,4,opt,name=msg_id,json=msgId,proto3" json:"msg_id,omitempty"` // 消息id
Data []byte `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"` // 消息体
sizeCache protoimpl.SizeCache
}
func (x *ClientMsg) Reset() {
*x = ClientMsg{}
if protoimpl.UnsafeEnabled {
mi := &file_client_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_client_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ClientMsg) String() string {
@ -49,7 +47,7 @@ func (*ClientMsg) ProtoMessage() {}
func (x *ClientMsg) ProtoReflect() protoreflect.Message {
mi := &file_client_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -101,38 +99,31 @@ func (x *ClientMsg) GetData() []byte {
var File_client_proto protoreflect.FileDescriptor
var file_client_proto_rawDesc = []byte{
0x0a, 0x0c, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02,
0x70, 0x62, 0x1a, 0x0d, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x22, 0xa6, 0x01, 0x0a, 0x09, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4d, 0x73, 0x67, 0x12,
0x32, 0x0a, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x74, 0x69, 0x64, 0x18, 0x01,
0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
0x65, 0x54, 0x79, 0x70, 0x65, 0x49, 0x64, 0x52, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x54, 0x69, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x6e,
0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x69,
0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69,
0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12,
0x15, 0x0a, 0x06, 0x6d, 0x73, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52,
0x05, 0x6d, 0x73, 0x67, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x05,
0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x11, 0x5a, 0x0f, 0x63, 0x6f,
0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
}
const file_client_proto_rawDesc = "" +
"\n" +
"\fclient.proto\x12\x02pb\x1a\rservice.proto\"\xa6\x01\n" +
"\tClientMsg\x122\n" +
"\vservice_tid\x18\x01 \x01(\x0e2\x11.pb.ServiceTypeIdR\n" +
"serviceTid\x12!\n" +
"\fservice_name\x18\x02 \x01(\tR\vserviceName\x12\x17\n" +
"\auser_id\x18\x03 \x01(\x03R\x06userId\x12\x15\n" +
"\x06msg_id\x18\x04 \x01(\x05R\x05msgId\x12\x12\n" +
"\x04data\x18\x05 \x01(\fR\x04dataB\x11Z\x0fcommon/proto/pbb\x06proto3"
var (
file_client_proto_rawDescOnce sync.Once
file_client_proto_rawDescData = file_client_proto_rawDesc
file_client_proto_rawDescData []byte
)
func file_client_proto_rawDescGZIP() []byte {
file_client_proto_rawDescOnce.Do(func() {
file_client_proto_rawDescData = protoimpl.X.CompressGZIP(file_client_proto_rawDescData)
file_client_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_client_proto_rawDesc), len(file_client_proto_rawDesc)))
})
return file_client_proto_rawDescData
}
var file_client_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_client_proto_goTypes = []interface{}{
var file_client_proto_goTypes = []any{
(*ClientMsg)(nil), // 0: pb.ClientMsg
(ServiceTypeId)(0), // 1: pb.ServiceTypeId
}
@ -151,25 +142,11 @@ func file_client_proto_init() {
return
}
file_service_proto_init()
if !protoimpl.UnsafeEnabled {
file_client_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ClientMsg); 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_client_proto_rawDesc,
RawDescriptor: unsafe.Slice(unsafe.StringData(file_client_proto_rawDesc), len(file_client_proto_rawDesc)),
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
@ -180,7 +157,6 @@ func file_client_proto_init() {
MessageInfos: file_client_proto_msgTypes,
}.Build()
File_client_proto = out.File
file_client_proto_rawDesc = nil
file_client_proto_goTypes = nil
file_client_proto_depIdxs = nil
}

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.34.1
// protoc v4.25.2
// protoc-gen-go v1.36.6
// protoc v6.31.0
// source: code.proto
package pb
@ -11,6 +11,7 @@ import (
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
@ -89,37 +90,35 @@ func (ErrCode) EnumDescriptor() ([]byte, []int) {
var File_code_proto protoreflect.FileDescriptor
var file_code_proto_rawDesc = []byte{
0x0a, 0x0a, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62,
0x2a, 0xa7, 0x01, 0x0a, 0x07, 0x45, 0x72, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x06, 0x0a, 0x02,
0x4f, 0x4b, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x45, 0x72,
0x72, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x44, 0x69, 0x66, 0x66,
0x4c, 0x6f, 0x63, 0x10, 0x64, 0x12, 0x15, 0x0a, 0x11, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x55, 0x73,
0x65, 0x72, 0x4f, 0x72, 0x50, 0x77, 0x64, 0x45, 0x72, 0x72, 0x10, 0x66, 0x12, 0x11, 0x0a, 0x0d,
0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x46, 0x72, 0x6f, 0x7a, 0x65, 0x6e, 0x10, 0x67, 0x12,
0x11, 0x0a, 0x0d, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x42, 0x61, 0x6e, 0x6e, 0x65, 0x64,
0x10, 0x68, 0x12, 0x15, 0x0a, 0x11, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x55, 0x73,
0x65, 0x72, 0x45, 0x78, 0x69, 0x73, 0x74, 0x10, 0x6e, 0x12, 0x11, 0x0a, 0x0d, 0x56, 0x65, 0x72,
0x73, 0x69, 0x6f, 0x6e, 0x54, 0x6f, 0x6f, 0x4c, 0x6f, 0x77, 0x10, 0x73, 0x12, 0x0c, 0x0a, 0x08,
0x4d, 0x61, 0x69, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x10, 0x78, 0x42, 0x11, 0x5a, 0x0f, 0x63, 0x6f,
0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
}
const file_code_proto_rawDesc = "" +
"\n" +
"\n" +
"code.proto\x12\x02pb*\xa7\x01\n" +
"\aErrCode\x12\x06\n" +
"\x02OK\x10\x00\x12\r\n" +
"\tSystemErr\x10\x01\x12\x10\n" +
"\fLoginDiffLoc\x10d\x12\x15\n" +
"\x11LoginUserOrPwdErr\x10f\x12\x11\n" +
"\rAccountFrozen\x10g\x12\x11\n" +
"\rAccountBanned\x10h\x12\x15\n" +
"\x11RegisterUserExist\x10n\x12\x11\n" +
"\rVersionTooLow\x10s\x12\f\n" +
"\bMaintain\x10xB\x11Z\x0fcommon/proto/pbb\x06proto3"
var (
file_code_proto_rawDescOnce sync.Once
file_code_proto_rawDescData = file_code_proto_rawDesc
file_code_proto_rawDescData []byte
)
func file_code_proto_rawDescGZIP() []byte {
file_code_proto_rawDescOnce.Do(func() {
file_code_proto_rawDescData = protoimpl.X.CompressGZIP(file_code_proto_rawDescData)
file_code_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_code_proto_rawDesc), len(file_code_proto_rawDesc)))
})
return file_code_proto_rawDescData
}
var file_code_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_code_proto_goTypes = []interface{}{
var file_code_proto_goTypes = []any{
(ErrCode)(0), // 0: pb.ErrCode
}
var file_code_proto_depIdxs = []int32{
@ -139,7 +138,7 @@ func file_code_proto_init() {
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_code_proto_rawDesc,
RawDescriptor: unsafe.Slice(unsafe.StringData(file_code_proto_rawDesc), len(file_code_proto_rawDesc)),
NumEnums: 1,
NumMessages: 0,
NumExtensions: 0,
@ -150,7 +149,6 @@ func file_code_proto_init() {
EnumInfos: file_code_proto_enumTypes,
}.Build()
File_code_proto = out.File
file_code_proto_rawDesc = nil
file_code_proto_goTypes = nil
file_code_proto_depIdxs = nil
}

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.34.1
// protoc v4.25.2
// protoc-gen-go v1.36.6
// protoc v6.31.0
// source: login.proto
package pb
@ -11,6 +11,7 @@ import (
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
@ -22,24 +23,21 @@ const (
// 玩家登陆
type C2SUserLogin struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` // 用户名
Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` // 密码或token
Ip string `protobuf:"bytes,3,opt,name=ip,proto3" json:"ip,omitempty"`
DeviceId string `protobuf:"bytes,4,opt,name=device_id,json=deviceId,proto3" json:"device_id,omitempty"` // 设备id
Version string `protobuf:"bytes,10,opt,name=version,proto3" json:"version,omitempty"` // 版本
unknownFields protoimpl.UnknownFields
Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` // 用户名
Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` // 密码或token
Ip string `protobuf:"bytes,3,opt,name=ip,proto3" json:"ip,omitempty"`
DeviceId string `protobuf:"bytes,4,opt,name=device_id,json=deviceId,proto3" json:"device_id,omitempty"` // 设备id
Version string `protobuf:"bytes,10,opt,name=version,proto3" json:"version,omitempty"` // 版本
sizeCache protoimpl.SizeCache
}
func (x *C2SUserLogin) Reset() {
*x = C2SUserLogin{}
if protoimpl.UnsafeEnabled {
mi := &file_login_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_login_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *C2SUserLogin) String() string {
@ -50,7 +48,7 @@ func (*C2SUserLogin) ProtoMessage() {}
func (x *C2SUserLogin) ProtoReflect() protoreflect.Message {
mi := &file_login_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -101,22 +99,19 @@ func (x *C2SUserLogin) GetVersion() string {
}
type S2CUserLogin struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
Code ErrCode `protobuf:"varint,1,opt,name=code,proto3,enum=pb.ErrCode" json:"code,omitempty"`
UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
Token string `protobuf:"bytes,3,opt,name=token,proto3" json:"token,omitempty"` // token
unknownFields protoimpl.UnknownFields
Code ErrCode `protobuf:"varint,1,opt,name=code,proto3,enum=pb.ErrCode" json:"code,omitempty"`
UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
Token string `protobuf:"bytes,3,opt,name=token,proto3" json:"token,omitempty"` // token
sizeCache protoimpl.SizeCache
}
func (x *S2CUserLogin) Reset() {
*x = S2CUserLogin{}
if protoimpl.UnsafeEnabled {
mi := &file_login_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_login_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *S2CUserLogin) String() string {
@ -127,7 +122,7 @@ func (*S2CUserLogin) ProtoMessage() {}
func (x *S2CUserLogin) ProtoReflect() protoreflect.Message {
mi := &file_login_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -165,20 +160,17 @@ func (x *S2CUserLogin) GetToken() string {
// 上线通知
type NtfUserOnline struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // 玩家id
unknownFields protoimpl.UnknownFields
UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // 玩家id
sizeCache protoimpl.SizeCache
}
func (x *NtfUserOnline) Reset() {
*x = NtfUserOnline{}
if protoimpl.UnsafeEnabled {
mi := &file_login_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_login_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *NtfUserOnline) String() string {
@ -189,7 +181,7 @@ func (*NtfUserOnline) ProtoMessage() {}
func (x *NtfUserOnline) ProtoReflect() protoreflect.Message {
mi := &file_login_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -213,18 +205,16 @@ func (x *NtfUserOnline) GetUserId() int64 {
// 玩家登陆
type C2SUserLogout struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *C2SUserLogout) Reset() {
*x = C2SUserLogout{}
if protoimpl.UnsafeEnabled {
mi := &file_login_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_login_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *C2SUserLogout) String() string {
@ -235,7 +225,7 @@ func (*C2SUserLogout) ProtoMessage() {}
func (x *C2SUserLogout) ProtoReflect() protoreflect.Message {
mi := &file_login_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -251,20 +241,17 @@ func (*C2SUserLogout) Descriptor() ([]byte, []int) {
}
type S2CUserLogout struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
Code ErrCode `protobuf:"varint,1,opt,name=code,proto3,enum=pb.ErrCode" json:"code,omitempty"` // 登出原因
unknownFields protoimpl.UnknownFields
Code ErrCode `protobuf:"varint,1,opt,name=code,proto3,enum=pb.ErrCode" json:"code,omitempty"` // 登出原因
sizeCache protoimpl.SizeCache
}
func (x *S2CUserLogout) Reset() {
*x = S2CUserLogout{}
if protoimpl.UnsafeEnabled {
mi := &file_login_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_login_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *S2CUserLogout) String() string {
@ -275,7 +262,7 @@ func (*S2CUserLogout) ProtoMessage() {}
func (x *S2CUserLogout) ProtoReflect() protoreflect.Message {
mi := &file_login_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -299,20 +286,17 @@ func (x *S2CUserLogout) GetCode() ErrCode {
// 下线通知
type NtfUserOffline struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // 玩家id
unknownFields protoimpl.UnknownFields
UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // 玩家id
sizeCache protoimpl.SizeCache
}
func (x *NtfUserOffline) Reset() {
*x = NtfUserOffline{}
if protoimpl.UnsafeEnabled {
mi := &file_login_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_login_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *NtfUserOffline) String() string {
@ -323,7 +307,7 @@ func (*NtfUserOffline) ProtoMessage() {}
func (x *NtfUserOffline) ProtoReflect() protoreflect.Message {
mi := &file_login_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -347,51 +331,43 @@ func (x *NtfUserOffline) GetUserId() int64 {
var File_login_proto protoreflect.FileDescriptor
var file_login_proto_rawDesc = []byte{
0x0a, 0x0b, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70,
0x62, 0x1a, 0x0a, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8d, 0x01,
0x0a, 0x0c, 0x43, 0x32, 0x53, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x1a,
0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61,
0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61,
0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x03, 0x20, 0x01,
0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x12, 0x1b, 0x0a, 0x09, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65,
0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x64, 0x65, 0x76, 0x69, 0x63,
0x65, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x0a,
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x5e, 0x0a,
0x0c, 0x53, 0x32, 0x43, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x1f, 0x0a,
0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0b, 0x2e, 0x70, 0x62,
0x2e, 0x45, 0x72, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x17,
0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52,
0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e,
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x28, 0x0a,
0x0d, 0x4e, 0x74, 0x66, 0x55, 0x73, 0x65, 0x72, 0x4f, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x17,
0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52,
0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x0f, 0x0a, 0x0d, 0x43, 0x32, 0x53, 0x55, 0x73,
0x65, 0x72, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x22, 0x30, 0x0a, 0x0d, 0x53, 0x32, 0x43, 0x55,
0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x12, 0x1f, 0x0a, 0x04, 0x63, 0x6f, 0x64,
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0b, 0x2e, 0x70, 0x62, 0x2e, 0x45, 0x72, 0x72,
0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x22, 0x29, 0x0a, 0x0e, 0x4e, 0x74,
0x66, 0x55, 0x73, 0x65, 0x72, 0x4f, 0x66, 0x66, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x17, 0x0a, 0x07,
0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75,
0x73, 0x65, 0x72, 0x49, 0x64, 0x42, 0x11, 0x5a, 0x0f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
const file_login_proto_rawDesc = "" +
"\n" +
"\vlogin.proto\x12\x02pb\x1a\n" +
"code.proto\"\x8d\x01\n" +
"\fC2SUserLogin\x12\x1a\n" +
"\busername\x18\x01 \x01(\tR\busername\x12\x1a\n" +
"\bpassword\x18\x02 \x01(\tR\bpassword\x12\x0e\n" +
"\x02ip\x18\x03 \x01(\tR\x02ip\x12\x1b\n" +
"\tdevice_id\x18\x04 \x01(\tR\bdeviceId\x12\x18\n" +
"\aversion\x18\n" +
" \x01(\tR\aversion\"^\n" +
"\fS2CUserLogin\x12\x1f\n" +
"\x04code\x18\x01 \x01(\x0e2\v.pb.ErrCodeR\x04code\x12\x17\n" +
"\auser_id\x18\x02 \x01(\x03R\x06userId\x12\x14\n" +
"\x05token\x18\x03 \x01(\tR\x05token\"(\n" +
"\rNtfUserOnline\x12\x17\n" +
"\auser_id\x18\x02 \x01(\x03R\x06userId\"\x0f\n" +
"\rC2SUserLogout\"0\n" +
"\rS2CUserLogout\x12\x1f\n" +
"\x04code\x18\x01 \x01(\x0e2\v.pb.ErrCodeR\x04code\")\n" +
"\x0eNtfUserOffline\x12\x17\n" +
"\auser_id\x18\x02 \x01(\x03R\x06userIdB\x11Z\x0fcommon/proto/pbb\x06proto3"
var (
file_login_proto_rawDescOnce sync.Once
file_login_proto_rawDescData = file_login_proto_rawDesc
file_login_proto_rawDescData []byte
)
func file_login_proto_rawDescGZIP() []byte {
file_login_proto_rawDescOnce.Do(func() {
file_login_proto_rawDescData = protoimpl.X.CompressGZIP(file_login_proto_rawDescData)
file_login_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_login_proto_rawDesc), len(file_login_proto_rawDesc)))
})
return file_login_proto_rawDescData
}
var file_login_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_login_proto_goTypes = []interface{}{
var file_login_proto_goTypes = []any{
(*C2SUserLogin)(nil), // 0: pb.C2SUserLogin
(*S2CUserLogin)(nil), // 1: pb.S2CUserLogin
(*NtfUserOnline)(nil), // 2: pb.NtfUserOnline
@ -416,85 +392,11 @@ func file_login_proto_init() {
return
}
file_code_proto_init()
if !protoimpl.UnsafeEnabled {
file_login_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*C2SUserLogin); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_login_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*S2CUserLogin); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_login_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*NtfUserOnline); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_login_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*C2SUserLogout); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_login_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*S2CUserLogout); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_login_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*NtfUserOffline); 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_login_proto_rawDesc,
RawDescriptor: unsafe.Slice(unsafe.StringData(file_login_proto_rawDesc), len(file_login_proto_rawDesc)),
NumEnums: 0,
NumMessages: 6,
NumExtensions: 0,
@ -505,7 +407,6 @@ func file_login_proto_init() {
MessageInfos: file_login_proto_msgTypes,
}.Build()
File_login_proto = out.File
file_login_proto_rawDesc = nil
file_login_proto_goTypes = nil
file_login_proto_depIdxs = nil
}

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.34.1
// protoc v4.25.2
// protoc-gen-go v1.36.6
// protoc v6.31.0
// source: msgId.proto
package pb
@ -11,6 +11,7 @@ import (
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
@ -98,39 +99,36 @@ func (MsgId) EnumDescriptor() ([]byte, []int) {
var File_msgId_proto protoreflect.FileDescriptor
var file_msgId_proto_rawDesc = []byte{
0x0a, 0x0b, 0x6d, 0x73, 0x67, 0x49, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70,
0x62, 0x2a, 0xce, 0x01, 0x0a, 0x05, 0x4d, 0x73, 0x67, 0x49, 0x64, 0x12, 0x0e, 0x0a, 0x0a, 0x4d,
0x49, 0x5f, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0d, 0x4e,
0x74, 0x66, 0x4d, 0x61, 0x69, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x10, 0xe8, 0x07, 0x12,
0x0e, 0x0a, 0x09, 0x43, 0x32, 0x53, 0x43, 0x68, 0x61, 0x74, 0x49, 0x64, 0x10, 0xd0, 0x0f, 0x12,
0x0e, 0x0a, 0x09, 0x53, 0x32, 0x43, 0x43, 0x68, 0x61, 0x74, 0x49, 0x64, 0x10, 0xd1, 0x0f, 0x12,
0x13, 0x0a, 0x0e, 0x43, 0x32, 0x53, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x49,
0x64, 0x10, 0xb4, 0x10, 0x12, 0x13, 0x0a, 0x0e, 0x53, 0x32, 0x43, 0x55, 0x73, 0x65, 0x72, 0x4c,
0x6f, 0x67, 0x69, 0x6e, 0x49, 0x64, 0x10, 0xb5, 0x10, 0x12, 0x14, 0x0a, 0x0f, 0x4e, 0x74, 0x66,
0x55, 0x73, 0x65, 0x72, 0x4f, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x64, 0x10, 0xb6, 0x10, 0x12,
0x14, 0x0a, 0x0f, 0x43, 0x32, 0x53, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74,
0x49, 0x64, 0x10, 0xb8, 0x10, 0x12, 0x14, 0x0a, 0x0f, 0x53, 0x32, 0x43, 0x55, 0x73, 0x65, 0x72,
0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x49, 0x64, 0x10, 0xb9, 0x10, 0x12, 0x15, 0x0a, 0x10, 0x4e,
0x74, 0x66, 0x55, 0x73, 0x65, 0x72, 0x4f, 0x66, 0x66, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x64, 0x10,
0xba, 0x10, 0x42, 0x11, 0x5a, 0x0f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
const file_msgId_proto_rawDesc = "" +
"\n" +
"\vmsgId.proto\x12\x02pb*\xce\x01\n" +
"\x05MsgId\x12\x0e\n" +
"\n" +
"MI_Unknown\x10\x00\x12\x12\n" +
"\rNtfMaintainId\x10\xe8\a\x12\x0e\n" +
"\tC2SChatId\x10\xd0\x0f\x12\x0e\n" +
"\tS2CChatId\x10\xd1\x0f\x12\x13\n" +
"\x0eC2SUserLoginId\x10\xb4\x10\x12\x13\n" +
"\x0eS2CUserLoginId\x10\xb5\x10\x12\x14\n" +
"\x0fNtfUserOnlineId\x10\xb6\x10\x12\x14\n" +
"\x0fC2SUserLogoutId\x10\xb8\x10\x12\x14\n" +
"\x0fS2CUserLogoutId\x10\xb9\x10\x12\x15\n" +
"\x10NtfUserOfflineId\x10\xba\x10B\x11Z\x0fcommon/proto/pbb\x06proto3"
var (
file_msgId_proto_rawDescOnce sync.Once
file_msgId_proto_rawDescData = file_msgId_proto_rawDesc
file_msgId_proto_rawDescData []byte
)
func file_msgId_proto_rawDescGZIP() []byte {
file_msgId_proto_rawDescOnce.Do(func() {
file_msgId_proto_rawDescData = protoimpl.X.CompressGZIP(file_msgId_proto_rawDescData)
file_msgId_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_msgId_proto_rawDesc), len(file_msgId_proto_rawDesc)))
})
return file_msgId_proto_rawDescData
}
var file_msgId_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_msgId_proto_goTypes = []interface{}{
var file_msgId_proto_goTypes = []any{
(MsgId)(0), // 0: pb.MsgId
}
var file_msgId_proto_depIdxs = []int32{
@ -150,7 +148,7 @@ func file_msgId_proto_init() {
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_msgId_proto_rawDesc,
RawDescriptor: unsafe.Slice(unsafe.StringData(file_msgId_proto_rawDesc), len(file_msgId_proto_rawDesc)),
NumEnums: 1,
NumMessages: 0,
NumExtensions: 0,
@ -161,7 +159,6 @@ func file_msgId_proto_init() {
EnumInfos: file_msgId_proto_enumTypes,
}.Build()
File_msgId_proto = out.File
file_msgId_proto_rawDesc = nil
file_msgId_proto_goTypes = nil
file_msgId_proto_depIdxs = nil
}

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.34.1
// protoc v4.25.2
// protoc-gen-go v1.36.6
// protoc v6.31.0
// source: service.proto
package pb
@ -11,6 +11,7 @@ import (
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
@ -23,11 +24,12 @@ const (
type ServiceTypeId int32
const (
ServiceTypeId_STI_Unknown ServiceTypeId = 0
ServiceTypeId_STI_Gate ServiceTypeId = 100 // 网关id
ServiceTypeId_STI_Login ServiceTypeId = 101 // 登陆服
ServiceTypeId_STI_Chat ServiceTypeId = 102 // 聊天服
ServiceTypeId_STI_DB ServiceTypeId = 103 // db服
ServiceTypeId_STI_Unknown ServiceTypeId = 0
ServiceTypeId_STI_Gate ServiceTypeId = 100 // 网关id
ServiceTypeId_STI_Login ServiceTypeId = 101 // 登陆服
ServiceTypeId_STI_Chat ServiceTypeId = 102 // 聊天服
ServiceTypeId_STI_DB ServiceTypeId = 103 // db服
ServiceTypeId_STI_ColorGame ServiceTypeId = 120 // color game
)
// Enum value maps for ServiceTypeId.
@ -38,13 +40,15 @@ var (
101: "STI_Login",
102: "STI_Chat",
103: "STI_DB",
120: "STI_ColorGame",
}
ServiceTypeId_value = map[string]int32{
"STI_Unknown": 0,
"STI_Gate": 100,
"STI_Login": 101,
"STI_Chat": 102,
"STI_DB": 103,
"STI_Unknown": 0,
"STI_Gate": 100,
"STI_Login": 101,
"STI_Chat": 102,
"STI_DB": 103,
"STI_ColorGame": 120,
}
)
@ -77,32 +81,32 @@ func (ServiceTypeId) EnumDescriptor() ([]byte, []int) {
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, 0x12,
0x02, 0x70, 0x62, 0x2a, 0x57, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79,
0x70, 0x65, 0x49, 0x64, 0x12, 0x0f, 0x0a, 0x0b, 0x53, 0x54, 0x49, 0x5f, 0x55, 0x6e, 0x6b, 0x6e,
0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x53, 0x54, 0x49, 0x5f, 0x47, 0x61, 0x74,
0x65, 0x10, 0x64, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x54, 0x49, 0x5f, 0x4c, 0x6f, 0x67, 0x69, 0x6e,
0x10, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x53, 0x54, 0x49, 0x5f, 0x43, 0x68, 0x61, 0x74, 0x10, 0x66,
0x12, 0x0a, 0x0a, 0x06, 0x53, 0x54, 0x49, 0x5f, 0x44, 0x42, 0x10, 0x67, 0x42, 0x11, 0x5a, 0x0f,
0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x62, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
const file_service_proto_rawDesc = "" +
"\n" +
"\rservice.proto\x12\x02pb*j\n" +
"\rServiceTypeId\x12\x0f\n" +
"\vSTI_Unknown\x10\x00\x12\f\n" +
"\bSTI_Gate\x10d\x12\r\n" +
"\tSTI_Login\x10e\x12\f\n" +
"\bSTI_Chat\x10f\x12\n" +
"\n" +
"\x06STI_DB\x10g\x12\x11\n" +
"\rSTI_ColorGame\x10xB\x11Z\x0fcommon/proto/pbb\x06proto3"
var (
file_service_proto_rawDescOnce sync.Once
file_service_proto_rawDescData = file_service_proto_rawDesc
file_service_proto_rawDescData []byte
)
func file_service_proto_rawDescGZIP() []byte {
file_service_proto_rawDescOnce.Do(func() {
file_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_service_proto_rawDescData)
file_service_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_service_proto_rawDesc), len(file_service_proto_rawDesc)))
})
return file_service_proto_rawDescData
}
var file_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_service_proto_goTypes = []interface{}{
var file_service_proto_goTypes = []any{
(ServiceTypeId)(0), // 0: pb.ServiceTypeId
}
var file_service_proto_depIdxs = []int32{
@ -122,7 +126,7 @@ func file_service_proto_init() {
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_service_proto_rawDesc,
RawDescriptor: unsafe.Slice(unsafe.StringData(file_service_proto_rawDesc), len(file_service_proto_rawDesc)),
NumEnums: 1,
NumMessages: 0,
NumExtensions: 0,
@ -133,7 +137,6 @@ func file_service_proto_init() {
EnumInfos: file_service_proto_enumTypes,
}.Build()
File_service_proto = out.File
file_service_proto_rawDesc = nil
file_service_proto_goTypes = nil
file_service_proto_depIdxs = nil
}

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.34.1
// protoc v4.25.2
// protoc-gen-go v1.36.6
// protoc v6.31.0
// source: user.proto
package pb
@ -11,6 +11,7 @@ import (
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
@ -22,24 +23,21 @@ const (
// 聊天中显示的玩家基础信息
type ChatUser struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
Nickname string `protobuf:"bytes,2,opt,name=nickname,proto3" json:"nickname,omitempty"` // 用户名
Avatar string `protobuf:"bytes,3,opt,name=avatar,proto3" json:"avatar,omitempty"` // 头像
AvatarFrame string `protobuf:"bytes,4,opt,name=avatar_frame,json=avatarFrame,proto3" json:"avatar_frame,omitempty"` // 头像框
VipLevel string `protobuf:"bytes,5,opt,name=vip_level,json=vipLevel,proto3" json:"vip_level,omitempty"` // vip等级
unknownFields protoimpl.UnknownFields
UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
Nickname string `protobuf:"bytes,2,opt,name=nickname,proto3" json:"nickname,omitempty"` // 用户名
Avatar string `protobuf:"bytes,3,opt,name=avatar,proto3" json:"avatar,omitempty"` // 头像
AvatarFrame string `protobuf:"bytes,4,opt,name=avatar_frame,json=avatarFrame,proto3" json:"avatar_frame,omitempty"` // 头像框
VipLevel string `protobuf:"bytes,5,opt,name=vip_level,json=vipLevel,proto3" json:"vip_level,omitempty"` // vip等级
sizeCache protoimpl.SizeCache
}
func (x *ChatUser) Reset() {
*x = ChatUser{}
if protoimpl.UnsafeEnabled {
mi := &file_user_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
mi := &file_user_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ChatUser) String() string {
@ -50,7 +48,7 @@ func (*ChatUser) ProtoMessage() {}
func (x *ChatUser) ProtoReflect() protoreflect.Message {
mi := &file_user_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
@ -102,36 +100,31 @@ func (x *ChatUser) GetVipLevel() string {
var File_user_proto protoreflect.FileDescriptor
var file_user_proto_rawDesc = []byte{
0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62,
0x22, 0x97, 0x01, 0x0a, 0x08, 0x43, 0x68, 0x61, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x17, 0x0a,
0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06,
0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61,
0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61,
0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x03, 0x20, 0x01,
0x28, 0x09, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x76,
0x61, 0x74, 0x61, 0x72, 0x5f, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09,
0x52, 0x0b, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a,
0x09, 0x76, 0x69, 0x70, 0x5f, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09,
0x52, 0x08, 0x76, 0x69, 0x70, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x42, 0x11, 0x5a, 0x0f, 0x63, 0x6f,
0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
}
const file_user_proto_rawDesc = "" +
"\n" +
"\n" +
"user.proto\x12\x02pb\"\x97\x01\n" +
"\bChatUser\x12\x17\n" +
"\auser_id\x18\x01 \x01(\x03R\x06userId\x12\x1a\n" +
"\bnickname\x18\x02 \x01(\tR\bnickname\x12\x16\n" +
"\x06avatar\x18\x03 \x01(\tR\x06avatar\x12!\n" +
"\favatar_frame\x18\x04 \x01(\tR\vavatarFrame\x12\x1b\n" +
"\tvip_level\x18\x05 \x01(\tR\bvipLevelB\x11Z\x0fcommon/proto/pbb\x06proto3"
var (
file_user_proto_rawDescOnce sync.Once
file_user_proto_rawDescData = file_user_proto_rawDesc
file_user_proto_rawDescData []byte
)
func file_user_proto_rawDescGZIP() []byte {
file_user_proto_rawDescOnce.Do(func() {
file_user_proto_rawDescData = protoimpl.X.CompressGZIP(file_user_proto_rawDescData)
file_user_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_user_proto_rawDesc), len(file_user_proto_rawDesc)))
})
return file_user_proto_rawDescData
}
var file_user_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_user_proto_goTypes = []interface{}{
var file_user_proto_goTypes = []any{
(*ChatUser)(nil), // 0: pb.ChatUser
}
var file_user_proto_depIdxs = []int32{
@ -147,25 +140,11 @@ func file_user_proto_init() {
if File_user_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_user_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ChatUser); 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_user_proto_rawDesc,
RawDescriptor: unsafe.Slice(unsafe.StringData(file_user_proto_rawDesc), len(file_user_proto_rawDesc)),
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
@ -176,7 +155,6 @@ func file_user_proto_init() {
MessageInfos: file_user_proto_msgTypes,
}.Build()
File_user_proto = out.File
file_user_proto_rawDesc = nil
file_user_proto_goTypes = nil
file_user_proto_depIdxs = nil
}

View File

@ -5,4 +5,7 @@ const (
Chat = "chat"
Login = "login"
Db = "db"
// 下面是具体玩法服
ColorGame = "color_game"
)

View File

@ -5,12 +5,71 @@ import (
"game/common/constant"
"github.com/fox/fox/db"
"github.com/fox/fox/log"
"github.com/go-redis/redis/v8"
)
const (
specialKey = "color_config"
)
var Command *config.Command
var Cfg *config.Common[LoginConfig]
var Cfg *config.Common[ColorConfig]
type LoginConfig struct {
type MulRate struct {
Mul int64 `json:"mul"` // 赔率
Rate int `json:"rate"` // 概率
}
type RoomConfig struct {
RoomType int `json:"room_type"` // 房间类型:初级,低级,中级,高级
Name string `json:"name"` // 游戏房间名称
Blind int64 `json:"blind"` // 底注
Rate int64 `json:"rate"` // 房间明税率
WinSingleColorWeight []int `json:"win_single_color_weight"` // 胜利单色奖励三个权重
WinSingleColorMul [][]*MulRate `json:"win_single_color_mul"` // 胜利单色奖励赔率 (1个同色,2个同色,3个同色)
WinDoubleColorMul []*MulRate `json:"win_double_color_mul"` // 胜利双色奖励赔率
WinThreeColorMul []*MulRate `json:"win_three_color_mul"` // 胜利三色奖励赔率
InitJackpot int64 `json:"init_jackpot"` // 初始jackpot值
JackpotRate int `json:"jackpot_rate"` // 单色投注区域每个颜色出现jackpot的概率
JpXRate int `json:"jp_x_rate"` // jp池赎回比例
JpYRate int `json:"jp_y_rate"` // jp池追加比例
JpXYRate int `json:"jp_xy_rate"` // 系统池为正时jackpot追加比例
AreaBetLimit int64 `json:"area_bet_limit"` // 下注区域自己的下注限制
NoBetCountMax int `json:"no_bet_count_max"` // 未操作回合踢出房间
BetList [][]int64 `json:"bet_list"` // 筹码
BetLevel []int64 `json:"bet_level"` // 筹码等级
OneCreateMin int32 `json:"one_create_min"` // 一次创建机器最少数
OneCreateMax int32 `json:"one_create_max"` // 一次创建机器人最大数
UserAddRobotNum int32 `json:"user_add_robot_num"` // 真人+机器人最小数
UserAddRobotNumMax int32 `json:"user_add_robot_num_max"` // 真人+机器人最大数
OneDeleteNum int32 `json:"one_delete_num"` // 一次删除机器人数量
BalanceMin int64 `json:"balance_min"` // 机器人生成最小金币
BalanceMax int64 `json:"balance_max"` // 机器人生成最大金币
BalanceMinDelete int64 `json:"balance_min_delete"` // 机器人低于多少金币删除
RobotCreateTime int32 `json:"robot_create_time"` // 多少时间创建机器人
RobotDeleteTime int32 `json:"robot_delete_time"` // 多少时间删除机器人
RobotBetNumMin int32 `json:"robot_bet_num_min"` // 机器人每轮下注最少次数
RobotBetNumMax int32 `json:"robot_bet_num_max"` // 机器人每轮下注最大次数
OpenRobot bool `json:"open_robot"` // 机器人开关
BetMap map[int64][]int32
TotalBetLimit int64 `json:"total_bet_limit"`
}
type GameTiming struct {
//Ready int64 // 准备倒计时
Start int64 // 开始
Betting int64 // 下注
EndBetting int64 // 结束下注
OpenThreeDice int64 // 开普通3个骰子
Settle int64 // 结算
//Ranking int64 // 排行榜
}
type ColorConfig struct {
Rooms []*RoomConfig `json:"rooms"` // 房间信息
GameTiming *GameTiming `json:"game_timing"`
}
func InitLog() {
@ -29,10 +88,86 @@ func LoadConfig(GitCommit, GitBranch, BuildDate string) {
return
}
defer func() { _ = rdb.Close() }()
Cfg, err = config.LoadCommonConfig[LoginConfig](rdb, GitCommit, GitBranch, BuildDate)
Cfg, err = config.LoadCommonConfig[ColorConfig](rdb, GitCommit, GitBranch, BuildDate)
if err != nil {
log.Error(err.Error())
return
}
log.DebugF("load common config success")
LoadColorConfig(rdb)
}
func LoadColorConfig(rdb *redis.Client) {
if err := config.LoadSpecialConfig[ColorConfig](rdb, specialKey, Cfg); err == nil {
return
}
Cfg.Special = &ColorConfig{}
Cfg.Special.GameTiming = &GameTiming{
//Ready: 100, // 倒计时321
Start: 2000,
Betting: 15000,
EndBetting: 3000,
OpenThreeDice: 3000,
Settle: 7000,
//Ranking: 1000,
}
WinSingleColorWeight := [3]int{50, 25, 25}
WinSingleColorMul := [3][]*MulRate{
{{Mul: 0.6 * 100, Rate: 75 * 100}, {Mul: 1 * 100, Rate: 12 * 100},
{Mul: 1.5 * 100, Rate: 7.5 * 100}, {Mul: 2 * 100, Rate: 5.5 * 100}},
{{Mul: 2 * 100, Rate: 82.5 * 100}, {Mul: 3 * 100, Rate: 4 * 100},
{Mul: 4 * 100, Rate: 3.5 * 100}, {Mul: 5 * 100, Rate: 3.2 * 100},
{Mul: 6 * 100, Rate: 230}, {Mul: 7 * 100, Rate: 1.8 * 100},
{Mul: 8 * 100, Rate: 1.5 * 100}, {Mul: 9 * 100, Rate: 1.2 * 100}},
{{Mul: 3 * 100, Rate: 94 * 100}, {Mul: 9 * 100, Rate: 1.4 * 100},
{Mul: 14 * 100, Rate: 110}, {Mul: 19 * 100, Rate: 0.9 * 100},
{Mul: 29 * 100, Rate: 0.8 * 100}, {Mul: 49 * 100, Rate: 0.7 * 100},
{Mul: 99 * 100, Rate: 0.6 * 100}, {Mul: 9 * 100, Rate: 0.5 * 100}},
}
WinDoubleColorMul := []*MulRate{{Mul: 8 * 100, Rate: 66 * 100}, {Mul: 11 * 100, Rate: 17 * 100},
{Mul: 14 * 100, Rate: 9 * 100}, {Mul: 19 * 100, Rate: 3.5 * 100},
{Mul: 24 * 100, Rate: 1.9 * 100}, {Mul: 54 * 100, Rate: 1.5 * 100},
{Mul: 74 * 100, Rate: 1.05 * 100}, {Mul: 99 * 100, Rate: 0.05 * 100}}
WinThreeColorMul := []*MulRate{{Mul: 150 * 100, Rate: 84.5 * 100}, {Mul: 199 * 100, Rate: 5.5 * 100},
{Mul: 299 * 100, Rate: 4 * 100}, {Mul: 599 * 100, Rate: 3 * 100},
{Mul: 799 * 100, Rate: 2 * 100}, {Mul: 999 * 100, Rate: 1 * 100}}
rmConfig := &RoomConfig{
BetList: [][]int64{
{1000, 2000, 3000, 5000, 10000, 20000},
{5000, 20000, 30000, 40000, 50000, 800000},
{10000, 20000, 30000, 50000, 80000, 100000},
},
BetLevel: []int64{0, 10000, 20000},
WinSingleColorWeight: WinSingleColorWeight[:],
WinSingleColorMul: WinSingleColorMul[:],
WinDoubleColorMul: WinDoubleColorMul,
WinThreeColorMul: WinThreeColorMul,
InitJackpot: 2000000 * 100,
JackpotRate: 0.05 * 100,
JpXRate: 2 * 100,
JpYRate: 1 * 100,
JpXYRate: 1.5 * 100,
AreaBetLimit: 500000,
NoBetCountMax: 10,
OpenRobot: false,
OneCreateMin: 3,
OneCreateMax: 5,
UserAddRobotNum: 80,
UserAddRobotNumMax: 100,
OneDeleteNum: 1,
BalanceMinDelete: 4000,
BalanceMin: 100000,
BalanceMax: 500000,
RobotCreateTime: 8000,
RobotDeleteTime: 5000,
RobotBetNumMin: 2,
RobotBetNumMax: 4,
}
Cfg.Special.Rooms = append(Cfg.Special.Rooms, rmConfig)
}

View File

@ -0,0 +1,18 @@
package room
import (
"game/common/baseroom"
"game/common/model/user"
)
type ColorPlayer struct {
user.User
}
func (p *ColorPlayer) Id() int64 {
return p.ID
}
func (p *ColorPlayer) Robot() baseroom.IRobot {
return nil
}

View File

@ -0,0 +1,22 @@
package room
import (
"game/common/baseroom"
"game/common/proto/pb"
"github.com/fox/fox/log"
)
type ColorRoom struct {
*baseroom.BaseRoom[ColorSeat]
}
func newColorRoom(id, roomType int) (baseroom.IRoom, pb.ErrCode) {
rm := &ColorRoom{}
playType := 0
code := pb.ErrCode_OK
rm.BaseRoom, code = baseroom.NewBaseRoom[ColorSeat](id, roomType, playType, rm, rm, rm)
if code != pb.ErrCode_OK {
log.ErrorF("new color room err code:%v", code)
}
return rm, code
}

View File

@ -0,0 +1,7 @@
package room
import "game/common/baseroom"
type ColorSeat struct {
*baseroom.BaseSeat
}

View File

@ -0,0 +1,27 @@
package room
import (
"game/common/baseroom"
"game/common/proto/pb"
)
type RoomFactory struct {
}
func (r *RoomFactory) CreateRoom(id, roomType int) (baseroom.IRoom, pb.ErrCode) {
return newColorRoom(id, roomType)
}
type PlayerFactory struct {
}
func (r *PlayerFactory) CreatePlayer(uid int64) (baseroom.IPlayer, pb.ErrCode) {
player := &ColorPlayer{}
code := pb.ErrCode_OK
return player, code
}
func GetPlayer(p baseroom.IPlayer) *ColorPlayer {
player, _ := p.(*ColorPlayer)
return player
}

View File

@ -19,13 +19,13 @@ const (
timeout = time.Second * 30
)
func (s *LoginService) initProcessor() {
func (s *ColorService) initProcessor() {
s.processor.RegisterMessages(processor.RegisterMetas{
pb.MsgId_C2SUserLoginId: {pb.C2SUserLogin{}, s.onLoginOrRegister},
})
}
func (s *LoginService) checkLoginOrRegister(req *pb.C2SUserLogin) (us *user.UserAccount, code pb.ErrCode, node *etcd.ServiceNode) {
func (s *ColorService) checkLoginOrRegister(req *pb.C2SUserLogin) (us *user.UserAccount, code pb.ErrCode, node *etcd.ServiceNode) {
var err error
node, err = s.bindService.RandServiceNode(pb.ServiceTypeId_STI_DB)
if err != nil {
@ -97,7 +97,7 @@ func generateToken(userID int64, username string) (string, error) {
}
// 获取用户数据,如果没有则创建
func (s *LoginService) getUser(accountId int64, tName string) (*user.User, pb.ErrCode) {
func (s *ColorService) getUser(accountId int64, tName string) (*user.User, pb.ErrCode) {
us := &user.User{
AccountId: accountId,
}
@ -116,7 +116,7 @@ func (s *LoginService) getUser(accountId int64, tName string) (*user.User, pb.Er
}
// 登录或注册
func (s *LoginService) onLoginOrRegister(iMsg *ipb.InternalMsg, req *pb.C2SUserLogin) {
func (s *ColorService) onLoginOrRegister(iMsg *ipb.InternalMsg, req *pb.C2SUserLogin) {
ksync.GoSafe(func() {
account, code, node := s.checkLoginOrRegister(req)
userId := int64(0)

View File

@ -2,11 +2,13 @@ package server
import (
"fmt"
"game/common/baseroom"
"game/common/proto/pb"
"game/common/serviceName"
"game/common/userBindService"
"game/server/colorgame/config"
"game/server/colorgame/model"
"game/server/colorgame/room"
"github.com/fox/fox/ipb"
"github.com/fox/fox/log"
"github.com/fox/fox/processor"
@ -14,48 +16,52 @@ import (
"github.com/golang/protobuf/proto"
)
var Login []*LoginService
var Color []service.IService
type LoginService struct {
type ColorService struct {
*service.NatsService
processor *processor.Processor
bindService *userBindService.UserBindService
roomMgr *baseroom.RoomMgr
playerMgr *baseroom.PlayerMgr
}
func Init() {
log.DebugF("init service begin id:%v, num:%v", config.Command.ServiceId, config.Command.ServiceNum)
for i := 0; i < config.Command.ServiceNum; i++ {
sid := config.Command.ServiceId + i
if srv := newLoginService(sid); srv != nil {
Login = append(Login, srv)
if srv := newColorService(sid); srv != nil {
Color = append(Color, srv)
}
}
}
func Stop() {
for _, srv := range Login {
for _, srv := range Color {
log.DebugF("notify stop service %v", srv.Name())
srv.NotifyStop()
}
for _, srv := range Login {
for _, srv := range Color {
srv.WaitStop()
}
}
func newLoginService(serviceId int) *LoginService {
func newColorService(serviceId int) service.IService {
var err error
s := new(LoginService)
s := new(ColorService)
s.roomMgr = baseroom.NewRoomMgr(&room.RoomFactory{})
sName := fmt.Sprintf("%v-%d", serviceName.Login, serviceId)
sName := fmt.Sprintf("%v-%d", serviceName.ColorGame, serviceId)
if s.NatsService, err = service.NewNatsService(&service.InitNatsServiceParams{
EtcdAddress: config.Cfg.Etcd.Address,
EtcdUsername: "",
EtcdPassword: "",
NatsAddress: config.Cfg.Nats.Address,
ServiceType: serviceName.Login,
ServiceType: serviceName.ColorGame,
ServiceName: sName,
OnFunc: s,
TypeId: int(pb.ServiceTypeId_STI_Login),
TypeId: int(pb.ServiceTypeId_STI_ColorGame),
Version: config.Cfg.BuildDate,
}); err != nil {
log.Fatal(err.Error())
@ -69,7 +75,7 @@ func newLoginService(serviceId int) *LoginService {
return s
}
func (s *LoginService) OnInit() {
func (s *ColorService) OnInit() {
// if err := s.NatsService.QueueSubscribe(service.GroupTopic(s), service.GroupQueue(s)); err != nil {
// log.Error(err.Error())
// }
@ -77,17 +83,22 @@ func (s *LoginService) OnInit() {
log.Debug("onInit")
}
func (s *LoginService) CanStop() bool {
func (s *ColorService) NotifyStop() {
s.roomMgr.SetStatus(baseroom.SsWaitStop)
s.BaseService.NotifyStop()
}
func (s *ColorService) CanStop() bool {
return true
}
func (s *LoginService) OnStop() {
func (s *ColorService) OnStop() {
s.NatsService.OnStop()
log.Debug("OnStop")
}
// 处理其它服发送过来的消息
func (s *LoginService) OnMessage(data []byte) error {
func (s *ColorService) OnMessage(data []byte) error {
var iMsg = &ipb.InternalMsg{}
var err error
if err = proto.Unmarshal(data, iMsg); err != nil {
@ -104,13 +115,13 @@ func (s *LoginService) OnMessage(data []byte) error {
}
// 向内部服务发送消息
func (s *LoginService) SendServiceData(topic string, connId uint32, userId int64, msgId int32, data []byte) {
func (s *ColorService) SendServiceData(topic string, connId uint32, userId int64, msgId int32, data []byte) {
iMsg := ipb.MakeMsg(s.Name(), connId, userId, msgId, data)
_ = s.Send(topic, iMsg)
}
// 向内部服务发送消息
func (s *LoginService) SendServiceMsg(topic string, connId uint32, userId int64, msgId int32, msg proto.Message) {
func (s *ColorService) SendServiceMsg(topic string, connId uint32, userId int64, msgId int32, msg proto.Message) {
data, _ := proto.Marshal(msg)
s.SendServiceData(topic, connId, userId, msgId, data)
}

View File

@ -3,7 +3,7 @@
1.02 启动1000个链接每小时固定发送登陆消息一天后查看连接是否还在。检查心跳机制。(已修复)
1.03 修改完后清除调试日志。(已完成)
1.04 客户端stop关闭连接触发服务端连接崩溃。(已修复)
1.05 偶现网络关闭服务端此时传来数据网关会因为conn为nil触发协程崩溃不影响程序运行。
1.05 偶现网络关闭服务端此时传来数据网关会因为conn为nil触发协程崩溃不影响程序运行。(暂不处理)
2.编写db服
2.01 login服向db服请求数据及向log db服写入日志。测试rpc机制。(已验证)
@ -14,11 +14,14 @@
2.06 struct序列化到redis中时需要处理时间格式。(已修复)
2.07 清理登陆相关调试日志。(已完成)
2.08 login服切换到其它地方启动后gate服会路由失败。(已修复etcd没有删除失效节点导致。)
2.09 login在创建帐号时还需要创建user。(已实现,待验证)
2.09 login在创建帐号时还需要创建user。(已实现,待验证) todo
3.编写color game玩法
3.1 服务端玩法
3.2 客户端用控制台编写逻辑不涉及ui
3.01 房间配置。(已完成)
3.02 创建房间、加载玩家数据。
3.03 停服时能及时关闭服务。(需要检查房间管理器)
3.04 具体业务实现。
3.20 客户端用控制台编写逻辑不涉及ui
4. 编写管理后台
4.1 玩法配置