base room
This commit is contained in:
parent
75f00fa6df
commit
8cc514ecf7
259
common/baseroom/baseRoom.go
Normal file
259
common/baseroom/baseRoom.go
Normal file
@ -0,0 +1,259 @@
|
|||||||
|
package baseroom
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
truthRoom IRoom
|
||||||
|
sTimer timer.ITimer
|
||||||
|
sender ISender
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewBaseRoom[Seat ISeat](id, roomType, playType int) (*BaseRoom[Seat], pb.ErrCode) {
|
||||||
|
room := &BaseRoom[Seat]{
|
||||||
|
id: id,
|
||||||
|
roomType: roomType,
|
||||||
|
playType: playType,
|
||||||
|
gameNo: "",
|
||||||
|
timeTypes: make(map[TimerType]uint32),
|
||||||
|
}
|
||||||
|
|
||||||
|
return room, pb.ErrCode_OK
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *BaseRoom[Seat]) Id() int {
|
||||||
|
return r.id
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *BaseRoom[Seat]) RoomType() int {
|
||||||
|
return r.roomType
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *BaseRoom[Seat]) SetTruthRoom(rm IRoom) {
|
||||||
|
r.truthRoom = rm
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *BaseRoom[Seat]) PlayType() int {
|
||||||
|
return r.playType
|
||||||
|
}
|
||||||
|
|
||||||
|
// 入座玩家数量(包含机器人)
|
||||||
|
func (r *BaseRoom[Seat]) SeatPlayerNum() int {
|
||||||
|
num := 0
|
||||||
|
for _, seat := range r.Seats {
|
||||||
|
if !seat.Empty() {
|
||||||
|
num++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return num
|
||||||
|
}
|
||||||
|
|
||||||
|
// 真实玩家数量
|
||||||
|
func (r *BaseRoom[Seat]) RealPlayerNum() int {
|
||||||
|
num := 0
|
||||||
|
for _, seat := range r.Seats {
|
||||||
|
if !seat.Empty() && seat.Player().Robot() == nil {
|
||||||
|
num++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return num
|
||||||
|
}
|
||||||
|
|
||||||
|
// 机器人数量
|
||||||
|
func (r *BaseRoom[Seat]) RobotPlayerNum() int {
|
||||||
|
num := 0
|
||||||
|
for _, seat := range r.Seats {
|
||||||
|
if !seat.Empty() && seat.Player().Robot() != nil {
|
||||||
|
num++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return num
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *BaseRoom[Seat]) HasEmptySeat() bool {
|
||||||
|
for _, seat := range r.Seats {
|
||||||
|
if seat.Empty() {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
r.Seats[seat].SetPlayer(player)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *BaseRoom[Seat]) RemovePlayer(player IPlayer) {
|
||||||
|
for _, seat := range r.Seats {
|
||||||
|
if !seat.Empty() && seat.Player().Id() == player.Id() {
|
||||||
|
seat.SetPlayer(nil)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *BaseRoom[Seat]) OnMessage(_ string, _ map[string]interface{}) {}
|
||||||
|
|
||||||
|
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()))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *BaseRoom[Seat]) SendMsg(user IPlayer, msgId pb.MsgId, msg proto.Message) {
|
||||||
|
r.DebugSendMsg(user, msgId, msg)
|
||||||
|
if user.Robot() != nil {
|
||||||
|
user.Robot().OnMessage(msgId, msg)
|
||||||
|
} else {
|
||||||
|
for _, seat := range r.Seats {
|
||||||
|
if !seat.Empty() && seat.Player().Id() == user.Id() {
|
||||||
|
r.sender.SendMsg(user, msgId, msg)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *BaseRoom[Seat]) Broadcast(msgId pb.MsgId, msg proto.Message, exclude ...IPlayer) {
|
||||||
|
for _, seat := range r.Seats {
|
||||||
|
if !seat.Empty() {
|
||||||
|
exist := false
|
||||||
|
for _, excludePlayer := range exclude {
|
||||||
|
if excludePlayer.Id() == seat.Player().Id() {
|
||||||
|
exist = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !exist {
|
||||||
|
r.SendMsg(seat.Player(), msgId, msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *BaseRoom[Seat]) NewTimer(timerType TimerType, duration time.Duration, args ...interface{}) {
|
||||||
|
if r.timerHandler == nil {
|
||||||
|
log.Error(r.Log("timer handler is nil"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if _, ok := r.timeTypes[timerType]; ok {
|
||||||
|
log.Error(r.Log("timer type:%v is exist.can not new timer", timerType.String()))
|
||||||
|
// if timerType == TtPlayerAct {
|
||||||
|
// log.Debug(r.Log(log.StackTrace()))
|
||||||
|
// }
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tid := r.sTimer.NewTimer(duration+time.Duration(10)*time.Millisecond, func() {
|
||||||
|
r.timerHandler.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()))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *BaseRoom[Seat]) CancelTimer(timerType TimerType) {
|
||||||
|
if tid, ok := r.timeTypes[timerType]; ok {
|
||||||
|
r.sTimer.CancelTimer(tid)
|
||||||
|
delete(r.timeTypes, timerType)
|
||||||
|
// log.Debug(r.Log("stop type:%v timer, rest timer:%+v", timerType.String(), r.timeTypes))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *BaseRoom[Seat]) CancelAllTimer() {
|
||||||
|
for _, tid := range r.timeTypes {
|
||||||
|
r.sTimer.CancelTimer(tid)
|
||||||
|
// log.Debug(r.Log("start type:%v timer", timerType.String()))
|
||||||
|
}
|
||||||
|
r.timeTypes = make(map[TimerType]uint32)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *BaseRoom[Seat]) Log(format string, a ...any) string {
|
||||||
|
head := fmt.Sprintf("room:%v type:%v ", r.id, r.roomType)
|
||||||
|
return head + fmt.Sprintf(format, a...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *BaseRoom[Seat]) SeatLog(seat Seat, format string, a ...any) string {
|
||||||
|
head := ""
|
||||||
|
if seat.Player() != nil {
|
||||||
|
head = fmt.Sprintf("room:%v type:%v seat:%v user:%v robot:%v ", r.id, r.roomType, seat.No(), seat.Player().Id(), seat.Player().Robot() != nil)
|
||||||
|
} else {
|
||||||
|
head = fmt.Sprintf("room:%v type:%v seat:%v ", r.id, r.roomType, seat.No())
|
||||||
|
}
|
||||||
|
|
||||||
|
return head + fmt.Sprintf(format, a...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *BaseRoom[Seat]) UserLog(uid int64, format string, a ...any) string {
|
||||||
|
var seat Seat
|
||||||
|
exist := false
|
||||||
|
for _, st := range r.Seats {
|
||||||
|
if !st.Empty() && st.Player().Id() == uid {
|
||||||
|
seat = st
|
||||||
|
exist = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if exist {
|
||||||
|
return r.SeatLog(seat, format, a...)
|
||||||
|
} else {
|
||||||
|
return r.Log(format, a...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 玩家俱乐部房间玩游戏
|
||||||
|
func (r *BaseRoom[Seat]) GameStart() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 玩家俱乐部房间玩游戏
|
||||||
|
func (r *BaseRoom[Seat]) GameEnd() {
|
||||||
|
|
||||||
|
}
|
77
common/baseroom/baseSeat.go
Normal file
77
common/baseroom/baseSeat.go
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
package baseroom
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BaseSeat struct {
|
||||||
|
no int
|
||||||
|
player IPlayer
|
||||||
|
fakeLeave bool
|
||||||
|
isCurrent bool // 多开时,该标记true为玩家的当前桌
|
||||||
|
canAct bool // true:当前能叫分或出牌
|
||||||
|
ready bool
|
||||||
|
seatedTime time.Time // 落座的时间
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewBaseSeat(no int) *BaseSeat {
|
||||||
|
return &BaseSeat{no: no}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SeatedTime 落座时间
|
||||||
|
func (s *BaseSeat) SeatedTime() time.Time {
|
||||||
|
return s.seatedTime
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *BaseSeat) No() int {
|
||||||
|
return s.no
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *BaseSeat) Empty() bool {
|
||||||
|
return s.player == nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *BaseSeat) Player() IPlayer {
|
||||||
|
return s.player
|
||||||
|
}
|
||||||
|
|
||||||
|
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) 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
|
||||||
|
}
|
14
common/baseroom/base_test.go
Normal file
14
common/baseroom/base_test.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package baseroom
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestConst(t *testing.T) {
|
||||||
|
_ = SsWorking
|
||||||
|
_ = SsStopped
|
||||||
|
_ = SsWaitStop
|
||||||
|
_ = NewRoomMgr
|
||||||
|
_ = NewBaseRoom[*BaseSeat]
|
||||||
|
_ = NewBaseSeat
|
||||||
|
}
|
51
common/baseroom/gameLog.go
Normal file
51
common/baseroom/gameLog.go
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package baseroom
|
||||||
|
|
||||||
|
// // 物品
|
||||||
|
// type Item struct {
|
||||||
|
// Id int `json:"id"` // 物品id
|
||||||
|
// Num int64 `json:"num"` // 物品数量
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// type BasePlayerLog struct {
|
||||||
|
// UId int64 `json:"uid"` // 玩家id
|
||||||
|
// Seat int `json:"seat"` // 座位号
|
||||||
|
// TakeCoin int64 `json:"initial_coins"` // 携带金币
|
||||||
|
// WinCoin int64 `json:"win_coins"` // 输赢金币
|
||||||
|
// EndCoin int64 `json:"end_coins"` // 结束金币
|
||||||
|
// Tip int64 `json:"charge"` // 台费
|
||||||
|
// CostItem []Item `json:"cost_item"` // 消耗物品
|
||||||
|
// Robot int `json:"robot"` // 机器人标识 0:机器人 1:真人
|
||||||
|
// RobotTemper int `json:"robot_temper"` // 机器人性格 0:未知 1:稳健 2:激进 3:普通 4:摆烂 5:策略型
|
||||||
|
// EmoteNum int `json:"emote_num"` // 玩家发送的表情次数
|
||||||
|
// FreeScore int64 `json:"free_score"` // 免费积分
|
||||||
|
// InoutScore int64 `json:"inout_score"` // 可提现的免费积分
|
||||||
|
// MoneyScore int64 `json:"money_score"` // 充值积分
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 房间对局写入redis的对局日志
|
||||||
|
// type BaseGameLog struct {
|
||||||
|
// RoomId int `json:"room_id"` // 房间id
|
||||||
|
// RoomType int `json:"room_type"` // 房间类型
|
||||||
|
// Level int `json:"level"` // 房间等级:低中高级场
|
||||||
|
// PlayType int `json:"play_type"` // 玩法类型
|
||||||
|
// Blind int64 `json:"bet"` // 底注
|
||||||
|
// GameNo string `json:"game_no"` // 本局唯一id 游戏开始之后赋值
|
||||||
|
// StartTime int64 `json:"start_time"` // 开始时间 游戏开始之后赋值
|
||||||
|
// EndTime int64 `json:"end_time"` // 结束时间 游戏结束之后赋值
|
||||||
|
// Players []interface{} `json:"players"` // 玩家数据 游戏结束之后赋值(涉及到输赢金币)
|
||||||
|
// ClubId int `json:"club_id"` // 当前俱乐部id 0:金币场
|
||||||
|
// PlatformFee int64 `json:"platform_fee"` // 平台分佣(消耗俱乐部部长身上的俱乐部币) 俱乐部分成之后赋值
|
||||||
|
// ClubFee int64 `json:"club_fee"` // 俱乐部分佣 俱乐部分成之后赋值
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 游戏开始之后赋值
|
||||||
|
// func (t *BaseGameLog) StartGame(startTime int64, gameNo string) {
|
||||||
|
// t.StartTime = startTime
|
||||||
|
// t.GameNo = gameNo
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// func (t *BaseGameLog) EndGame(endTime int64, players []interface{}) {
|
||||||
|
// t.EndTime = endTime
|
||||||
|
// t.Players = players
|
||||||
|
// // model.AddRoomGameLog(t.PlayType, t)
|
||||||
|
// }
|
58
common/baseroom/gameLog_test.go
Normal file
58
common/baseroom/gameLog_test.go
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
package baseroom
|
||||||
|
|
||||||
|
// type PlayerLog struct {
|
||||||
|
// UId int64 `json:"uid"` // 玩家id
|
||||||
|
// Seat int `json:"seat"` // 座位号
|
||||||
|
// CostItem []Item `json:"cost_item"` // 消耗物品
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// type GameLogT struct {
|
||||||
|
// Players []*PlayerLog `json:"players"` // 玩家数据
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// type StructM struct {
|
||||||
|
// Players []map[string]interface{} `json:"players"` // 玩家数据
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// type B struct {
|
||||||
|
// I int `json:"i"`
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// type B2 struct {
|
||||||
|
// I2 int `json:"i2"`
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// func (b *B) GetId() int {
|
||||||
|
// return b.I
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// type C struct {
|
||||||
|
// *B
|
||||||
|
// *B2
|
||||||
|
// Z int `json:"z"`
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 测试添加金币
|
||||||
|
// func TestStruct(t *testing.T) {
|
||||||
|
// //game := new(BaseGameLog)
|
||||||
|
// //game.Players = append(game.Players, &BasePlayerLog{UId: 1, Seat: 0, CostItem: []ItemLog{{Id: 10, Num: 10}, {Id: 11, Num: 11}}})
|
||||||
|
// //game.Players = append(game.Players, &BasePlayerLog{UId: 2, Seat: 1, CostItem: []ItemLog{{Id: 20, Num: 20}, {Id: 21, Num: 21}}})
|
||||||
|
// //b1, _ := json.Marshal(game)
|
||||||
|
// m := new(StructM)
|
||||||
|
// p1 := map[string]interface{}{"uid": 1, "seat": 0, "cost_item": []Item{{Id: 10, Num: 10}, {Id: 11, Num: 11}}}
|
||||||
|
// p2 := map[string]interface{}{"uid": 2, "seat": 1, "cost_item": []Item{{Id: 20, Num: 20}, {Id: 21, Num: 21}}}
|
||||||
|
// m.Players = append(m.Players, p1)
|
||||||
|
// m.Players = append(m.Players, p2)
|
||||||
|
// b2, _ := json.Marshal(m)
|
||||||
|
//
|
||||||
|
// game := new(GameLogT)
|
||||||
|
// _ = json.Unmarshal(b2, game)
|
||||||
|
// b1, _ := json.Marshal(game)
|
||||||
|
//
|
||||||
|
// t.Log(string(b1))
|
||||||
|
// t.Log(string(b2))
|
||||||
|
//
|
||||||
|
// c := C{B: &B{I: 10}, B2: &B2{I2: 12}, Z: 1}
|
||||||
|
// sc, _ := json.Marshal(c)
|
||||||
|
// t.Log(string(sc))
|
||||||
|
// }
|
45
common/baseroom/interface.go
Normal file
45
common/baseroom/interface.go
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package baseroom
|
||||||
|
|
||||||
|
import "game/common/proto/pb"
|
||||||
|
|
||||||
|
type IRoom interface {
|
||||||
|
Id() int
|
||||||
|
RoomType() int // 房间配置id
|
||||||
|
PlayType() int
|
||||||
|
// SeatPlayerNum() int
|
||||||
|
// HasEmptySeat() bool
|
||||||
|
// HasPlayer(uid int64) bool
|
||||||
|
OnMessage(cmd int32, params ...any)
|
||||||
|
// ReleaseRoom()
|
||||||
|
}
|
||||||
|
|
||||||
|
type ISeat interface {
|
||||||
|
No() int
|
||||||
|
Empty() bool
|
||||||
|
Player() IPlayer
|
||||||
|
SetPlayer(player IPlayer)
|
||||||
|
FakeLeave() bool
|
||||||
|
SetFakeLeave(leave bool)
|
||||||
|
// SeatedTime() time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
type IPlayer interface {
|
||||||
|
Id() int64
|
||||||
|
Robot() IRobot
|
||||||
|
}
|
||||||
|
|
||||||
|
type IRobot interface {
|
||||||
|
OnMessage(cmd pb.MsgId, params ...any)
|
||||||
|
}
|
||||||
|
|
||||||
|
type ITimerHandler interface {
|
||||||
|
OnTimer(timerType TimerType, args ...interface{})
|
||||||
|
}
|
||||||
|
|
||||||
|
type ISender interface {
|
||||||
|
SendMsg(user IPlayer, msgId pb.MsgId, msg interface{})
|
||||||
|
}
|
||||||
|
|
||||||
|
type ICreateRoom interface {
|
||||||
|
CreateRoom(id, roomType int) (IRoom, pb.ErrCode)
|
||||||
|
}
|
91
common/baseroom/roomMgr.go
Normal file
91
common/baseroom/roomMgr.go
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
package baseroom
|
||||||
|
|
||||||
|
import (
|
||||||
|
"game/common/proto/pb"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ServiceStatus int
|
||||||
|
|
||||||
|
const (
|
||||||
|
SsWorking ServiceStatus = 0
|
||||||
|
SsWaitStop ServiceStatus = 1
|
||||||
|
SsStopped ServiceStatus = 2
|
||||||
|
)
|
||||||
|
|
||||||
|
type RoomMgr struct {
|
||||||
|
rooms map[int]IRoom
|
||||||
|
createRoom ICreateRoom
|
||||||
|
status ServiceStatus // 服务状态
|
||||||
|
no int
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewRoomMgr(create ICreateRoom) *RoomMgr {
|
||||||
|
return &RoomMgr{
|
||||||
|
rooms: make(map[int]IRoom),
|
||||||
|
createRoom: create,
|
||||||
|
status: SsWorking,
|
||||||
|
no: 100000,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *RoomMgr) Count() int {
|
||||||
|
return len(s.rooms)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *RoomMgr) Init() {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *RoomMgr) Add(room IRoom) {
|
||||||
|
s.rooms[room.Id()] = room
|
||||||
|
}
|
||||||
|
|
||||||
|
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]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *RoomMgr) Status() ServiceStatus {
|
||||||
|
return s.status
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *RoomMgr) SetStatus(ss ServiceStatus) {
|
||||||
|
s.status = ss
|
||||||
|
}
|
||||||
|
|
||||||
|
// FindWaitRooms 获取所有未开始游戏的房间
|
||||||
|
func (s *RoomMgr) Filter(predicate func(IRoom) bool) []IRoom {
|
||||||
|
rooms := make([]IRoom, 0)
|
||||||
|
for _, room := range s.rooms {
|
||||||
|
if predicate(room) {
|
||||||
|
rooms = append(rooms, room)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rooms
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *RoomMgr) makeRoomId() int {
|
||||||
|
s.no++
|
||||||
|
return s.no
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *RoomMgr) CreateRoom(roomType int) (room IRoom, code pb.ErrCode) {
|
||||||
|
if s.status != SsWorking {
|
||||||
|
return nil, pb.ErrCode_Maintain
|
||||||
|
}
|
||||||
|
roomId := s.makeRoomId()
|
||||||
|
if roomId < 0 {
|
||||||
|
return nil, pb.ErrCode_SystemErr
|
||||||
|
}
|
||||||
|
room, code = s.createRoom.CreateRoom(roomId, roomType)
|
||||||
|
if room != nil {
|
||||||
|
s.Add(room)
|
||||||
|
}
|
||||||
|
return room, code
|
||||||
|
}
|
55
common/baseroom/timerType.go
Normal file
55
common/baseroom/timerType.go
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
package baseroom
|
||||||
|
|
||||||
|
type TimerType int
|
||||||
|
|
||||||
|
const (
|
||||||
|
TtUnknown TimerType = 0
|
||||||
|
|
||||||
|
TtDealPoker TimerType = 200 // 发牌结束后通知玩家行动
|
||||||
|
TtDecidingGame TimerType = 201 // 决胜局展示手牌及同意,放弃行动
|
||||||
|
TtPlayerAct TimerType = 202 // 玩家行动
|
||||||
|
TtPlayerRspRaise TimerType = 204 // 玩家回应行动
|
||||||
|
TtCmpPoker TimerType = 205 // 比牌
|
||||||
|
TtNextGame TimerType = 208 // 下一小局
|
||||||
|
// TtGameEnd TimerType = 205 // 大局结束,询问玩家是否继续
|
||||||
|
// TtContinue TimerType = 206 // 继续
|
||||||
|
TtSecond TimerType = 220 // 每秒定时器
|
||||||
|
TtGameReadyStart TimerType = 221 // 游戏开始倒计时
|
||||||
|
TtEnterRoom TimerType = 222
|
||||||
|
// TtEmote TimerType = 223 // 发送表情
|
||||||
|
|
||||||
|
TtPlayerCutLine TimerType = 401 // 插队
|
||||||
|
TtDelDisbandRoomInfo TimerType = 402 // 删除解散房间投票
|
||||||
|
)
|
||||||
|
|
||||||
|
func (t TimerType) String() string {
|
||||||
|
switch t {
|
||||||
|
case TtUnknown:
|
||||||
|
return "unknown"
|
||||||
|
case TtDealPoker:
|
||||||
|
return "TtDealPoker"
|
||||||
|
case TtDecidingGame:
|
||||||
|
return "TtDecidingGame"
|
||||||
|
case TtPlayerAct:
|
||||||
|
return "TtPlayerAct"
|
||||||
|
case TtPlayerRspRaise:
|
||||||
|
return "TtPlayerRspRaise"
|
||||||
|
case TtCmpPoker:
|
||||||
|
return "TtCmpPoker"
|
||||||
|
case TtNextGame:
|
||||||
|
return "TtNextGame"
|
||||||
|
case TtPlayerCutLine:
|
||||||
|
return "TtPlayerCutLine"
|
||||||
|
// case TtContinue:
|
||||||
|
// return "TtContinue"
|
||||||
|
case TtSecond:
|
||||||
|
return "TtSecond"
|
||||||
|
case TtGameReadyStart:
|
||||||
|
return "TtGameReadyStart"
|
||||||
|
case TtDelDisbandRoomInfo:
|
||||||
|
return "TtDelDisbandRoomInfo"
|
||||||
|
case TtEnterRoom:
|
||||||
|
return "TtEnterRoom"
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
@ -12,6 +12,8 @@ enum ErrCode
|
|||||||
AccountBanned = 104; // 帐号已封禁
|
AccountBanned = 104; // 帐号已封禁
|
||||||
RegisterUserExist = 110; // 已有该帐号,无法注册
|
RegisterUserExist = 110; // 已有该帐号,无法注册
|
||||||
VersionTooLow = 115; // 版本太低,无法登陆
|
VersionTooLow = 115; // 版本太低,无法登陆
|
||||||
|
|
||||||
|
Maintain = 120; // 系统维护
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@ enum MsgId
|
|||||||
{
|
{
|
||||||
MI_Unknown = 0;
|
MI_Unknown = 0;
|
||||||
|
|
||||||
|
NtfMaintainId = 1000; // 通知维护
|
||||||
|
|
||||||
// 聊天服 2000-2100
|
// 聊天服 2000-2100
|
||||||
C2SChatId = 2000; // 玩家聊天消息
|
C2SChatId = 2000; // 玩家聊天消息
|
||||||
S2CChatId = 2001; // 复用C2SChatMsg
|
S2CChatId = 2001; // 复用C2SChatMsg
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.36.6
|
// protoc-gen-go v1.34.1
|
||||||
// protoc v6.31.0
|
// protoc v4.25.2
|
||||||
// source: chat.proto
|
// source: chat.proto
|
||||||
|
|
||||||
package pb
|
package pb
|
||||||
@ -11,7 +11,6 @@ import (
|
|||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
sync "sync"
|
sync "sync"
|
||||||
unsafe "unsafe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -76,21 +75,24 @@ func (ChatType) EnumDescriptor() ([]byte, []int) {
|
|||||||
|
|
||||||
// 聊天消息
|
// 聊天消息
|
||||||
type C2SChat struct {
|
type C2SChat struct {
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState
|
||||||
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
|
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
|
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"` // 内容
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *C2SChat) Reset() {
|
func (x *C2SChat) Reset() {
|
||||||
*x = C2SChat{}
|
*x = C2SChat{}
|
||||||
mi := &file_chat_proto_msgTypes[0]
|
if protoimpl.UnsafeEnabled {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
mi := &file_chat_proto_msgTypes[0]
|
||||||
ms.StoreMessageInfo(mi)
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *C2SChat) String() string {
|
func (x *C2SChat) String() string {
|
||||||
@ -101,7 +103,7 @@ func (*C2SChat) ProtoMessage() {}
|
|||||||
|
|
||||||
func (x *C2SChat) ProtoReflect() protoreflect.Message {
|
func (x *C2SChat) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_chat_proto_msgTypes[0]
|
mi := &file_chat_proto_msgTypes[0]
|
||||||
if x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
@ -153,41 +155,46 @@ func (x *C2SChat) GetContent() string {
|
|||||||
|
|
||||||
var File_chat_proto protoreflect.FileDescriptor
|
var File_chat_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
const file_chat_proto_rawDesc = "" +
|
var file_chat_proto_rawDesc = []byte{
|
||||||
"\n" +
|
0x0a, 0x0a, 0x63, 0x68, 0x61, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62,
|
||||||
"\n" +
|
0x1a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0d, 0x73, 0x65,
|
||||||
"chat.proto\x12\x02pb\x1a\n" +
|
0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc3, 0x01, 0x0a, 0x07,
|
||||||
"user.proto\x1a\rservice.proto\"\xc3\x01\n" +
|
0x43, 0x32, 0x53, 0x43, 0x68, 0x61, 0x74, 0x12, 0x27, 0x0a, 0x08, 0x73, 0x72, 0x63, 0x5f, 0x75,
|
||||||
"\aC2SChat\x12'\n" +
|
0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x62, 0x2e, 0x43,
|
||||||
"\bsrc_user\x18\x01 \x01(\v2\f.pb.ChatUserR\asrcUser\x12'\n" +
|
0x68, 0x61, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x07, 0x73, 0x72, 0x63, 0x55, 0x73, 0x65, 0x72,
|
||||||
"\bdst_user\x18\x02 \x01(\v2\f.pb.ChatUserR\adstUser\x12 \n" +
|
0x12, 0x27, 0x0a, 0x08, 0x64, 0x73, 0x74, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01,
|
||||||
"\x04type\x18\x03 \x01(\x0e2\f.pb.ChatTypeR\x04type\x12*\n" +
|
0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x68, 0x61, 0x74, 0x55, 0x73, 0x65, 0x72,
|
||||||
"\agame_id\x18\x04 \x01(\x0e2\x11.pb.ServiceTypeIdR\x06gameId\x12\x18\n" +
|
0x52, 0x07, 0x64, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x20, 0x0a, 0x04, 0x74, 0x79, 0x70,
|
||||||
"\acontent\x18\x05 \x01(\tR\acontent*H\n" +
|
0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0c, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x68, 0x61,
|
||||||
"\bChatType\x12\x0e\n" +
|
0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x2a, 0x0a, 0x07, 0x67,
|
||||||
"\n" +
|
0x61, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e, 0x70,
|
||||||
"CT_Unknown\x10\x00\x12\x0e\n" +
|
0x62, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x49, 0x64, 0x52,
|
||||||
"\n" +
|
0x06, 0x67, 0x61, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65,
|
||||||
"CT_Private\x10\x01\x12\f\n" +
|
0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e,
|
||||||
"\bCT_World\x10\x02\x12\x0e\n" +
|
0x74, 0x2a, 0x48, 0x0a, 0x08, 0x43, 0x68, 0x61, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0e, 0x0a,
|
||||||
"\n" +
|
0x0a, 0x43, 0x54, 0x5f, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0e, 0x0a,
|
||||||
"CT_Marquee\x10\x03B\x11Z\x0fcommon/proto/pbb\x06proto3"
|
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,
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
file_chat_proto_rawDescOnce sync.Once
|
file_chat_proto_rawDescOnce sync.Once
|
||||||
file_chat_proto_rawDescData []byte
|
file_chat_proto_rawDescData = file_chat_proto_rawDesc
|
||||||
)
|
)
|
||||||
|
|
||||||
func file_chat_proto_rawDescGZIP() []byte {
|
func file_chat_proto_rawDescGZIP() []byte {
|
||||||
file_chat_proto_rawDescOnce.Do(func() {
|
file_chat_proto_rawDescOnce.Do(func() {
|
||||||
file_chat_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_chat_proto_rawDesc), len(file_chat_proto_rawDesc)))
|
file_chat_proto_rawDescData = protoimpl.X.CompressGZIP(file_chat_proto_rawDescData)
|
||||||
})
|
})
|
||||||
return file_chat_proto_rawDescData
|
return file_chat_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_chat_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
var file_chat_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||||
var file_chat_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
var file_chat_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||||
var file_chat_proto_goTypes = []any{
|
var file_chat_proto_goTypes = []interface{}{
|
||||||
(ChatType)(0), // 0: pb.ChatType
|
(ChatType)(0), // 0: pb.ChatType
|
||||||
(*C2SChat)(nil), // 1: pb.C2SChat
|
(*C2SChat)(nil), // 1: pb.C2SChat
|
||||||
(*ChatUser)(nil), // 2: pb.ChatUser
|
(*ChatUser)(nil), // 2: pb.ChatUser
|
||||||
@ -212,11 +219,25 @@ func file_chat_proto_init() {
|
|||||||
}
|
}
|
||||||
file_user_proto_init()
|
file_user_proto_init()
|
||||||
file_service_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{}
|
type x struct{}
|
||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
File: protoimpl.DescBuilder{
|
File: protoimpl.DescBuilder{
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_chat_proto_rawDesc), len(file_chat_proto_rawDesc)),
|
RawDescriptor: file_chat_proto_rawDesc,
|
||||||
NumEnums: 1,
|
NumEnums: 1,
|
||||||
NumMessages: 1,
|
NumMessages: 1,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
@ -228,6 +249,7 @@ func file_chat_proto_init() {
|
|||||||
MessageInfos: file_chat_proto_msgTypes,
|
MessageInfos: file_chat_proto_msgTypes,
|
||||||
}.Build()
|
}.Build()
|
||||||
File_chat_proto = out.File
|
File_chat_proto = out.File
|
||||||
|
file_chat_proto_rawDesc = nil
|
||||||
file_chat_proto_goTypes = nil
|
file_chat_proto_goTypes = nil
|
||||||
file_chat_proto_depIdxs = nil
|
file_chat_proto_depIdxs = nil
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.36.6
|
// protoc-gen-go v1.34.1
|
||||||
// protoc v6.31.0
|
// protoc v4.25.2
|
||||||
// source: client.proto
|
// source: client.proto
|
||||||
|
|
||||||
package pb
|
package pb
|
||||||
@ -11,7 +11,6 @@ import (
|
|||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
sync "sync"
|
sync "sync"
|
||||||
unsafe "unsafe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -22,21 +21,24 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ClientMsg struct {
|
type ClientMsg struct {
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState
|
||||||
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
|
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
|
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"` // 消息体
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *ClientMsg) Reset() {
|
func (x *ClientMsg) Reset() {
|
||||||
*x = ClientMsg{}
|
*x = ClientMsg{}
|
||||||
mi := &file_client_proto_msgTypes[0]
|
if protoimpl.UnsafeEnabled {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
mi := &file_client_proto_msgTypes[0]
|
||||||
ms.StoreMessageInfo(mi)
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *ClientMsg) String() string {
|
func (x *ClientMsg) String() string {
|
||||||
@ -47,7 +49,7 @@ func (*ClientMsg) ProtoMessage() {}
|
|||||||
|
|
||||||
func (x *ClientMsg) ProtoReflect() protoreflect.Message {
|
func (x *ClientMsg) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_client_proto_msgTypes[0]
|
mi := &file_client_proto_msgTypes[0]
|
||||||
if x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
@ -99,31 +101,38 @@ func (x *ClientMsg) GetData() []byte {
|
|||||||
|
|
||||||
var File_client_proto protoreflect.FileDescriptor
|
var File_client_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
const file_client_proto_rawDesc = "" +
|
var file_client_proto_rawDesc = []byte{
|
||||||
"\n" +
|
0x0a, 0x0c, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02,
|
||||||
"\fclient.proto\x12\x02pb\x1a\rservice.proto\"\xa6\x01\n" +
|
0x70, 0x62, 0x1a, 0x0d, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||||
"\tClientMsg\x122\n" +
|
0x6f, 0x22, 0xa6, 0x01, 0x0a, 0x09, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4d, 0x73, 0x67, 0x12,
|
||||||
"\vservice_tid\x18\x01 \x01(\x0e2\x11.pb.ServiceTypeIdR\n" +
|
0x32, 0x0a, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x74, 0x69, 0x64, 0x18, 0x01,
|
||||||
"serviceTid\x12!\n" +
|
0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
|
||||||
"\fservice_name\x18\x02 \x01(\tR\vserviceName\x12\x17\n" +
|
0x65, 0x54, 0x79, 0x70, 0x65, 0x49, 0x64, 0x52, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
|
||||||
"\auser_id\x18\x03 \x01(\x03R\x06userId\x12\x15\n" +
|
0x54, 0x69, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x6e,
|
||||||
"\x06msg_id\x18\x04 \x01(\x05R\x05msgId\x12\x12\n" +
|
0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x69,
|
||||||
"\x04data\x18\x05 \x01(\fR\x04dataB\x11Z\x0fcommon/proto/pbb\x06proto3"
|
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,
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
file_client_proto_rawDescOnce sync.Once
|
file_client_proto_rawDescOnce sync.Once
|
||||||
file_client_proto_rawDescData []byte
|
file_client_proto_rawDescData = file_client_proto_rawDesc
|
||||||
)
|
)
|
||||||
|
|
||||||
func file_client_proto_rawDescGZIP() []byte {
|
func file_client_proto_rawDescGZIP() []byte {
|
||||||
file_client_proto_rawDescOnce.Do(func() {
|
file_client_proto_rawDescOnce.Do(func() {
|
||||||
file_client_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_client_proto_rawDesc), len(file_client_proto_rawDesc)))
|
file_client_proto_rawDescData = protoimpl.X.CompressGZIP(file_client_proto_rawDescData)
|
||||||
})
|
})
|
||||||
return file_client_proto_rawDescData
|
return file_client_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_client_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
var file_client_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||||
var file_client_proto_goTypes = []any{
|
var file_client_proto_goTypes = []interface{}{
|
||||||
(*ClientMsg)(nil), // 0: pb.ClientMsg
|
(*ClientMsg)(nil), // 0: pb.ClientMsg
|
||||||
(ServiceTypeId)(0), // 1: pb.ServiceTypeId
|
(ServiceTypeId)(0), // 1: pb.ServiceTypeId
|
||||||
}
|
}
|
||||||
@ -142,11 +151,25 @@ func file_client_proto_init() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
file_service_proto_init()
|
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{}
|
type x struct{}
|
||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
File: protoimpl.DescBuilder{
|
File: protoimpl.DescBuilder{
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_client_proto_rawDesc), len(file_client_proto_rawDesc)),
|
RawDescriptor: file_client_proto_rawDesc,
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 1,
|
NumMessages: 1,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
@ -157,6 +180,7 @@ func file_client_proto_init() {
|
|||||||
MessageInfos: file_client_proto_msgTypes,
|
MessageInfos: file_client_proto_msgTypes,
|
||||||
}.Build()
|
}.Build()
|
||||||
File_client_proto = out.File
|
File_client_proto = out.File
|
||||||
|
file_client_proto_rawDesc = nil
|
||||||
file_client_proto_goTypes = nil
|
file_client_proto_goTypes = nil
|
||||||
file_client_proto_depIdxs = nil
|
file_client_proto_depIdxs = nil
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.36.6
|
// protoc-gen-go v1.34.1
|
||||||
// protoc v6.31.0
|
// protoc v4.25.2
|
||||||
// source: code.proto
|
// source: code.proto
|
||||||
|
|
||||||
package pb
|
package pb
|
||||||
@ -11,7 +11,6 @@ import (
|
|||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
sync "sync"
|
sync "sync"
|
||||||
unsafe "unsafe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -32,6 +31,7 @@ const (
|
|||||||
ErrCode_AccountBanned ErrCode = 104 // 帐号已封禁
|
ErrCode_AccountBanned ErrCode = 104 // 帐号已封禁
|
||||||
ErrCode_RegisterUserExist ErrCode = 110 // 已有该帐号,无法注册
|
ErrCode_RegisterUserExist ErrCode = 110 // 已有该帐号,无法注册
|
||||||
ErrCode_VersionTooLow ErrCode = 115 // 版本太低,无法登陆
|
ErrCode_VersionTooLow ErrCode = 115 // 版本太低,无法登陆
|
||||||
|
ErrCode_Maintain ErrCode = 120 // 系统维护
|
||||||
)
|
)
|
||||||
|
|
||||||
// Enum value maps for ErrCode.
|
// Enum value maps for ErrCode.
|
||||||
@ -45,6 +45,7 @@ var (
|
|||||||
104: "AccountBanned",
|
104: "AccountBanned",
|
||||||
110: "RegisterUserExist",
|
110: "RegisterUserExist",
|
||||||
115: "VersionTooLow",
|
115: "VersionTooLow",
|
||||||
|
120: "Maintain",
|
||||||
}
|
}
|
||||||
ErrCode_value = map[string]int32{
|
ErrCode_value = map[string]int32{
|
||||||
"OK": 0,
|
"OK": 0,
|
||||||
@ -55,6 +56,7 @@ var (
|
|||||||
"AccountBanned": 104,
|
"AccountBanned": 104,
|
||||||
"RegisterUserExist": 110,
|
"RegisterUserExist": 110,
|
||||||
"VersionTooLow": 115,
|
"VersionTooLow": 115,
|
||||||
|
"Maintain": 120,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -87,34 +89,37 @@ func (ErrCode) EnumDescriptor() ([]byte, []int) {
|
|||||||
|
|
||||||
var File_code_proto protoreflect.FileDescriptor
|
var File_code_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
const file_code_proto_rawDesc = "" +
|
var file_code_proto_rawDesc = []byte{
|
||||||
"\n" +
|
0x0a, 0x0a, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62,
|
||||||
"\n" +
|
0x2a, 0xa7, 0x01, 0x0a, 0x07, 0x45, 0x72, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x06, 0x0a, 0x02,
|
||||||
"code.proto\x12\x02pb*\x99\x01\n" +
|
0x4f, 0x4b, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x45, 0x72,
|
||||||
"\aErrCode\x12\x06\n" +
|
0x72, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x44, 0x69, 0x66, 0x66,
|
||||||
"\x02OK\x10\x00\x12\r\n" +
|
0x4c, 0x6f, 0x63, 0x10, 0x64, 0x12, 0x15, 0x0a, 0x11, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x55, 0x73,
|
||||||
"\tSystemErr\x10\x01\x12\x10\n" +
|
0x65, 0x72, 0x4f, 0x72, 0x50, 0x77, 0x64, 0x45, 0x72, 0x72, 0x10, 0x66, 0x12, 0x11, 0x0a, 0x0d,
|
||||||
"\fLoginDiffLoc\x10d\x12\x15\n" +
|
0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x46, 0x72, 0x6f, 0x7a, 0x65, 0x6e, 0x10, 0x67, 0x12,
|
||||||
"\x11LoginUserOrPwdErr\x10f\x12\x11\n" +
|
0x11, 0x0a, 0x0d, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x42, 0x61, 0x6e, 0x6e, 0x65, 0x64,
|
||||||
"\rAccountFrozen\x10g\x12\x11\n" +
|
0x10, 0x68, 0x12, 0x15, 0x0a, 0x11, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x55, 0x73,
|
||||||
"\rAccountBanned\x10h\x12\x15\n" +
|
0x65, 0x72, 0x45, 0x78, 0x69, 0x73, 0x74, 0x10, 0x6e, 0x12, 0x11, 0x0a, 0x0d, 0x56, 0x65, 0x72,
|
||||||
"\x11RegisterUserExist\x10n\x12\x11\n" +
|
0x73, 0x69, 0x6f, 0x6e, 0x54, 0x6f, 0x6f, 0x4c, 0x6f, 0x77, 0x10, 0x73, 0x12, 0x0c, 0x0a, 0x08,
|
||||||
"\rVersionTooLow\x10sB\x11Z\x0fcommon/proto/pbb\x06proto3"
|
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,
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
file_code_proto_rawDescOnce sync.Once
|
file_code_proto_rawDescOnce sync.Once
|
||||||
file_code_proto_rawDescData []byte
|
file_code_proto_rawDescData = file_code_proto_rawDesc
|
||||||
)
|
)
|
||||||
|
|
||||||
func file_code_proto_rawDescGZIP() []byte {
|
func file_code_proto_rawDescGZIP() []byte {
|
||||||
file_code_proto_rawDescOnce.Do(func() {
|
file_code_proto_rawDescOnce.Do(func() {
|
||||||
file_code_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_code_proto_rawDesc), len(file_code_proto_rawDesc)))
|
file_code_proto_rawDescData = protoimpl.X.CompressGZIP(file_code_proto_rawDescData)
|
||||||
})
|
})
|
||||||
return file_code_proto_rawDescData
|
return file_code_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_code_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
var file_code_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||||
var file_code_proto_goTypes = []any{
|
var file_code_proto_goTypes = []interface{}{
|
||||||
(ErrCode)(0), // 0: pb.ErrCode
|
(ErrCode)(0), // 0: pb.ErrCode
|
||||||
}
|
}
|
||||||
var file_code_proto_depIdxs = []int32{
|
var file_code_proto_depIdxs = []int32{
|
||||||
@ -134,7 +139,7 @@ func file_code_proto_init() {
|
|||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
File: protoimpl.DescBuilder{
|
File: protoimpl.DescBuilder{
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_code_proto_rawDesc), len(file_code_proto_rawDesc)),
|
RawDescriptor: file_code_proto_rawDesc,
|
||||||
NumEnums: 1,
|
NumEnums: 1,
|
||||||
NumMessages: 0,
|
NumMessages: 0,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
@ -145,6 +150,7 @@ func file_code_proto_init() {
|
|||||||
EnumInfos: file_code_proto_enumTypes,
|
EnumInfos: file_code_proto_enumTypes,
|
||||||
}.Build()
|
}.Build()
|
||||||
File_code_proto = out.File
|
File_code_proto = out.File
|
||||||
|
file_code_proto_rawDesc = nil
|
||||||
file_code_proto_goTypes = nil
|
file_code_proto_goTypes = nil
|
||||||
file_code_proto_depIdxs = nil
|
file_code_proto_depIdxs = nil
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.36.6
|
// protoc-gen-go v1.34.1
|
||||||
// protoc v6.31.0
|
// protoc v4.25.2
|
||||||
// source: login.proto
|
// source: login.proto
|
||||||
|
|
||||||
package pb
|
package pb
|
||||||
@ -11,7 +11,6 @@ import (
|
|||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
sync "sync"
|
sync "sync"
|
||||||
unsafe "unsafe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -23,21 +22,24 @@ const (
|
|||||||
|
|
||||||
// 玩家登陆
|
// 玩家登陆
|
||||||
type C2SUserLogin struct {
|
type C2SUserLogin struct {
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState
|
||||||
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
|
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
|
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"` // 版本
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *C2SUserLogin) Reset() {
|
func (x *C2SUserLogin) Reset() {
|
||||||
*x = C2SUserLogin{}
|
*x = C2SUserLogin{}
|
||||||
mi := &file_login_proto_msgTypes[0]
|
if protoimpl.UnsafeEnabled {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
mi := &file_login_proto_msgTypes[0]
|
||||||
ms.StoreMessageInfo(mi)
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *C2SUserLogin) String() string {
|
func (x *C2SUserLogin) String() string {
|
||||||
@ -48,7 +50,7 @@ func (*C2SUserLogin) ProtoMessage() {}
|
|||||||
|
|
||||||
func (x *C2SUserLogin) ProtoReflect() protoreflect.Message {
|
func (x *C2SUserLogin) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_login_proto_msgTypes[0]
|
mi := &file_login_proto_msgTypes[0]
|
||||||
if x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
@ -99,19 +101,22 @@ func (x *C2SUserLogin) GetVersion() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type S2CUserLogin struct {
|
type S2CUserLogin struct {
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState
|
||||||
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
|
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *S2CUserLogin) Reset() {
|
func (x *S2CUserLogin) Reset() {
|
||||||
*x = S2CUserLogin{}
|
*x = S2CUserLogin{}
|
||||||
mi := &file_login_proto_msgTypes[1]
|
if protoimpl.UnsafeEnabled {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
mi := &file_login_proto_msgTypes[1]
|
||||||
ms.StoreMessageInfo(mi)
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *S2CUserLogin) String() string {
|
func (x *S2CUserLogin) String() string {
|
||||||
@ -122,7 +127,7 @@ func (*S2CUserLogin) ProtoMessage() {}
|
|||||||
|
|
||||||
func (x *S2CUserLogin) ProtoReflect() protoreflect.Message {
|
func (x *S2CUserLogin) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_login_proto_msgTypes[1]
|
mi := &file_login_proto_msgTypes[1]
|
||||||
if x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
@ -160,17 +165,20 @@ func (x *S2CUserLogin) GetToken() string {
|
|||||||
|
|
||||||
// 上线通知
|
// 上线通知
|
||||||
type NtfUserOnline struct {
|
type NtfUserOnline struct {
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState
|
||||||
UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // 玩家id
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // 玩家id
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *NtfUserOnline) Reset() {
|
func (x *NtfUserOnline) Reset() {
|
||||||
*x = NtfUserOnline{}
|
*x = NtfUserOnline{}
|
||||||
mi := &file_login_proto_msgTypes[2]
|
if protoimpl.UnsafeEnabled {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
mi := &file_login_proto_msgTypes[2]
|
||||||
ms.StoreMessageInfo(mi)
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *NtfUserOnline) String() string {
|
func (x *NtfUserOnline) String() string {
|
||||||
@ -181,7 +189,7 @@ func (*NtfUserOnline) ProtoMessage() {}
|
|||||||
|
|
||||||
func (x *NtfUserOnline) ProtoReflect() protoreflect.Message {
|
func (x *NtfUserOnline) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_login_proto_msgTypes[2]
|
mi := &file_login_proto_msgTypes[2]
|
||||||
if x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
@ -205,16 +213,18 @@ func (x *NtfUserOnline) GetUserId() int64 {
|
|||||||
|
|
||||||
// 玩家登陆
|
// 玩家登陆
|
||||||
type C2SUserLogout struct {
|
type C2SUserLogout struct {
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *C2SUserLogout) Reset() {
|
func (x *C2SUserLogout) Reset() {
|
||||||
*x = C2SUserLogout{}
|
*x = C2SUserLogout{}
|
||||||
mi := &file_login_proto_msgTypes[3]
|
if protoimpl.UnsafeEnabled {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
mi := &file_login_proto_msgTypes[3]
|
||||||
ms.StoreMessageInfo(mi)
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *C2SUserLogout) String() string {
|
func (x *C2SUserLogout) String() string {
|
||||||
@ -225,7 +235,7 @@ func (*C2SUserLogout) ProtoMessage() {}
|
|||||||
|
|
||||||
func (x *C2SUserLogout) ProtoReflect() protoreflect.Message {
|
func (x *C2SUserLogout) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_login_proto_msgTypes[3]
|
mi := &file_login_proto_msgTypes[3]
|
||||||
if x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
@ -241,17 +251,20 @@ func (*C2SUserLogout) Descriptor() ([]byte, []int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type S2CUserLogout struct {
|
type S2CUserLogout struct {
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState
|
||||||
Code ErrCode `protobuf:"varint,1,opt,name=code,proto3,enum=pb.ErrCode" json:"code,omitempty"` // 登出原因
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Code ErrCode `protobuf:"varint,1,opt,name=code,proto3,enum=pb.ErrCode" json:"code,omitempty"` // 登出原因
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *S2CUserLogout) Reset() {
|
func (x *S2CUserLogout) Reset() {
|
||||||
*x = S2CUserLogout{}
|
*x = S2CUserLogout{}
|
||||||
mi := &file_login_proto_msgTypes[4]
|
if protoimpl.UnsafeEnabled {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
mi := &file_login_proto_msgTypes[4]
|
||||||
ms.StoreMessageInfo(mi)
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *S2CUserLogout) String() string {
|
func (x *S2CUserLogout) String() string {
|
||||||
@ -262,7 +275,7 @@ func (*S2CUserLogout) ProtoMessage() {}
|
|||||||
|
|
||||||
func (x *S2CUserLogout) ProtoReflect() protoreflect.Message {
|
func (x *S2CUserLogout) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_login_proto_msgTypes[4]
|
mi := &file_login_proto_msgTypes[4]
|
||||||
if x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
@ -286,17 +299,20 @@ func (x *S2CUserLogout) GetCode() ErrCode {
|
|||||||
|
|
||||||
// 下线通知
|
// 下线通知
|
||||||
type NtfUserOffline struct {
|
type NtfUserOffline struct {
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState
|
||||||
UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // 玩家id
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // 玩家id
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *NtfUserOffline) Reset() {
|
func (x *NtfUserOffline) Reset() {
|
||||||
*x = NtfUserOffline{}
|
*x = NtfUserOffline{}
|
||||||
mi := &file_login_proto_msgTypes[5]
|
if protoimpl.UnsafeEnabled {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
mi := &file_login_proto_msgTypes[5]
|
||||||
ms.StoreMessageInfo(mi)
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *NtfUserOffline) String() string {
|
func (x *NtfUserOffline) String() string {
|
||||||
@ -307,7 +323,7 @@ func (*NtfUserOffline) ProtoMessage() {}
|
|||||||
|
|
||||||
func (x *NtfUserOffline) ProtoReflect() protoreflect.Message {
|
func (x *NtfUserOffline) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_login_proto_msgTypes[5]
|
mi := &file_login_proto_msgTypes[5]
|
||||||
if x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
@ -331,43 +347,51 @@ func (x *NtfUserOffline) GetUserId() int64 {
|
|||||||
|
|
||||||
var File_login_proto protoreflect.FileDescriptor
|
var File_login_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
const file_login_proto_rawDesc = "" +
|
var file_login_proto_rawDesc = []byte{
|
||||||
"\n" +
|
0x0a, 0x0b, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70,
|
||||||
"\vlogin.proto\x12\x02pb\x1a\n" +
|
0x62, 0x1a, 0x0a, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8d, 0x01,
|
||||||
"code.proto\"\x8d\x01\n" +
|
0x0a, 0x0c, 0x43, 0x32, 0x53, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x1a,
|
||||||
"\fC2SUserLogin\x12\x1a\n" +
|
0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||||
"\busername\x18\x01 \x01(\tR\busername\x12\x1a\n" +
|
0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61,
|
||||||
"\bpassword\x18\x02 \x01(\tR\bpassword\x12\x0e\n" +
|
0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61,
|
||||||
"\x02ip\x18\x03 \x01(\tR\x02ip\x12\x1b\n" +
|
0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x03, 0x20, 0x01,
|
||||||
"\tdevice_id\x18\x04 \x01(\tR\bdeviceId\x12\x18\n" +
|
0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x12, 0x1b, 0x0a, 0x09, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65,
|
||||||
"\aversion\x18\n" +
|
0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x64, 0x65, 0x76, 0x69, 0x63,
|
||||||
" \x01(\tR\aversion\"^\n" +
|
0x65, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x0a,
|
||||||
"\fS2CUserLogin\x12\x1f\n" +
|
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x5e, 0x0a,
|
||||||
"\x04code\x18\x01 \x01(\x0e2\v.pb.ErrCodeR\x04code\x12\x17\n" +
|
0x0c, 0x53, 0x32, 0x43, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x1f, 0x0a,
|
||||||
"\auser_id\x18\x02 \x01(\x03R\x06userId\x12\x14\n" +
|
0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0b, 0x2e, 0x70, 0x62,
|
||||||
"\x05token\x18\x03 \x01(\tR\x05token\"(\n" +
|
0x2e, 0x45, 0x72, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x17,
|
||||||
"\rNtfUserOnline\x12\x17\n" +
|
0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52,
|
||||||
"\auser_id\x18\x02 \x01(\x03R\x06userId\"\x0f\n" +
|
0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e,
|
||||||
"\rC2SUserLogout\"0\n" +
|
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x28, 0x0a,
|
||||||
"\rS2CUserLogout\x12\x1f\n" +
|
0x0d, 0x4e, 0x74, 0x66, 0x55, 0x73, 0x65, 0x72, 0x4f, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x17,
|
||||||
"\x04code\x18\x01 \x01(\x0e2\v.pb.ErrCodeR\x04code\")\n" +
|
0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52,
|
||||||
"\x0eNtfUserOffline\x12\x17\n" +
|
0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x0f, 0x0a, 0x0d, 0x43, 0x32, 0x53, 0x55, 0x73,
|
||||||
"\auser_id\x18\x02 \x01(\x03R\x06userIdB\x11Z\x0fcommon/proto/pbb\x06proto3"
|
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,
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
file_login_proto_rawDescOnce sync.Once
|
file_login_proto_rawDescOnce sync.Once
|
||||||
file_login_proto_rawDescData []byte
|
file_login_proto_rawDescData = file_login_proto_rawDesc
|
||||||
)
|
)
|
||||||
|
|
||||||
func file_login_proto_rawDescGZIP() []byte {
|
func file_login_proto_rawDescGZIP() []byte {
|
||||||
file_login_proto_rawDescOnce.Do(func() {
|
file_login_proto_rawDescOnce.Do(func() {
|
||||||
file_login_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_login_proto_rawDesc), len(file_login_proto_rawDesc)))
|
file_login_proto_rawDescData = protoimpl.X.CompressGZIP(file_login_proto_rawDescData)
|
||||||
})
|
})
|
||||||
return file_login_proto_rawDescData
|
return file_login_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_login_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
var file_login_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
||||||
var file_login_proto_goTypes = []any{
|
var file_login_proto_goTypes = []interface{}{
|
||||||
(*C2SUserLogin)(nil), // 0: pb.C2SUserLogin
|
(*C2SUserLogin)(nil), // 0: pb.C2SUserLogin
|
||||||
(*S2CUserLogin)(nil), // 1: pb.S2CUserLogin
|
(*S2CUserLogin)(nil), // 1: pb.S2CUserLogin
|
||||||
(*NtfUserOnline)(nil), // 2: pb.NtfUserOnline
|
(*NtfUserOnline)(nil), // 2: pb.NtfUserOnline
|
||||||
@ -392,11 +416,85 @@ func file_login_proto_init() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
file_code_proto_init()
|
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{}
|
type x struct{}
|
||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
File: protoimpl.DescBuilder{
|
File: protoimpl.DescBuilder{
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_login_proto_rawDesc), len(file_login_proto_rawDesc)),
|
RawDescriptor: file_login_proto_rawDesc,
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 6,
|
NumMessages: 6,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
@ -407,6 +505,7 @@ func file_login_proto_init() {
|
|||||||
MessageInfos: file_login_proto_msgTypes,
|
MessageInfos: file_login_proto_msgTypes,
|
||||||
}.Build()
|
}.Build()
|
||||||
File_login_proto = out.File
|
File_login_proto = out.File
|
||||||
|
file_login_proto_rawDesc = nil
|
||||||
file_login_proto_goTypes = nil
|
file_login_proto_goTypes = nil
|
||||||
file_login_proto_depIdxs = nil
|
file_login_proto_depIdxs = nil
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.36.6
|
// protoc-gen-go v1.34.1
|
||||||
// protoc v6.31.0
|
// protoc v4.25.2
|
||||||
// source: msgId.proto
|
// source: msgId.proto
|
||||||
|
|
||||||
package pb
|
package pb
|
||||||
@ -11,7 +11,6 @@ import (
|
|||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
sync "sync"
|
sync "sync"
|
||||||
unsafe "unsafe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -28,7 +27,8 @@ const (
|
|||||||
type MsgId int32
|
type MsgId int32
|
||||||
|
|
||||||
const (
|
const (
|
||||||
MsgId_MI_Unknown MsgId = 0
|
MsgId_MI_Unknown MsgId = 0
|
||||||
|
MsgId_NtfMaintainId MsgId = 1000 // 通知维护
|
||||||
// 聊天服 2000-2100
|
// 聊天服 2000-2100
|
||||||
MsgId_C2SChatId MsgId = 2000 // 玩家聊天消息
|
MsgId_C2SChatId MsgId = 2000 // 玩家聊天消息
|
||||||
MsgId_S2CChatId MsgId = 2001 // 复用C2SChatMsg
|
MsgId_S2CChatId MsgId = 2001 // 复用C2SChatMsg
|
||||||
@ -45,6 +45,7 @@ const (
|
|||||||
var (
|
var (
|
||||||
MsgId_name = map[int32]string{
|
MsgId_name = map[int32]string{
|
||||||
0: "MI_Unknown",
|
0: "MI_Unknown",
|
||||||
|
1000: "NtfMaintainId",
|
||||||
2000: "C2SChatId",
|
2000: "C2SChatId",
|
||||||
2001: "S2CChatId",
|
2001: "S2CChatId",
|
||||||
2100: "C2SUserLoginId",
|
2100: "C2SUserLoginId",
|
||||||
@ -56,6 +57,7 @@ var (
|
|||||||
}
|
}
|
||||||
MsgId_value = map[string]int32{
|
MsgId_value = map[string]int32{
|
||||||
"MI_Unknown": 0,
|
"MI_Unknown": 0,
|
||||||
|
"NtfMaintainId": 1000,
|
||||||
"C2SChatId": 2000,
|
"C2SChatId": 2000,
|
||||||
"S2CChatId": 2001,
|
"S2CChatId": 2001,
|
||||||
"C2SUserLoginId": 2100,
|
"C2SUserLoginId": 2100,
|
||||||
@ -96,35 +98,39 @@ func (MsgId) EnumDescriptor() ([]byte, []int) {
|
|||||||
|
|
||||||
var File_msgId_proto protoreflect.FileDescriptor
|
var File_msgId_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
const file_msgId_proto_rawDesc = "" +
|
var file_msgId_proto_rawDesc = []byte{
|
||||||
"\n" +
|
0x0a, 0x0b, 0x6d, 0x73, 0x67, 0x49, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70,
|
||||||
"\vmsgId.proto\x12\x02pb*\xba\x01\n" +
|
0x62, 0x2a, 0xce, 0x01, 0x0a, 0x05, 0x4d, 0x73, 0x67, 0x49, 0x64, 0x12, 0x0e, 0x0a, 0x0a, 0x4d,
|
||||||
"\x05MsgId\x12\x0e\n" +
|
0x49, 0x5f, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0d, 0x4e,
|
||||||
"\n" +
|
0x74, 0x66, 0x4d, 0x61, 0x69, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x10, 0xe8, 0x07, 0x12,
|
||||||
"MI_Unknown\x10\x00\x12\x0e\n" +
|
0x0e, 0x0a, 0x09, 0x43, 0x32, 0x53, 0x43, 0x68, 0x61, 0x74, 0x49, 0x64, 0x10, 0xd0, 0x0f, 0x12,
|
||||||
"\tC2SChatId\x10\xd0\x0f\x12\x0e\n" +
|
0x0e, 0x0a, 0x09, 0x53, 0x32, 0x43, 0x43, 0x68, 0x61, 0x74, 0x49, 0x64, 0x10, 0xd1, 0x0f, 0x12,
|
||||||
"\tS2CChatId\x10\xd1\x0f\x12\x13\n" +
|
0x13, 0x0a, 0x0e, 0x43, 0x32, 0x53, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x49,
|
||||||
"\x0eC2SUserLoginId\x10\xb4\x10\x12\x13\n" +
|
0x64, 0x10, 0xb4, 0x10, 0x12, 0x13, 0x0a, 0x0e, 0x53, 0x32, 0x43, 0x55, 0x73, 0x65, 0x72, 0x4c,
|
||||||
"\x0eS2CUserLoginId\x10\xb5\x10\x12\x14\n" +
|
0x6f, 0x67, 0x69, 0x6e, 0x49, 0x64, 0x10, 0xb5, 0x10, 0x12, 0x14, 0x0a, 0x0f, 0x4e, 0x74, 0x66,
|
||||||
"\x0fNtfUserOnlineId\x10\xb6\x10\x12\x14\n" +
|
0x55, 0x73, 0x65, 0x72, 0x4f, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x64, 0x10, 0xb6, 0x10, 0x12,
|
||||||
"\x0fC2SUserLogoutId\x10\xb8\x10\x12\x14\n" +
|
0x14, 0x0a, 0x0f, 0x43, 0x32, 0x53, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74,
|
||||||
"\x0fS2CUserLogoutId\x10\xb9\x10\x12\x15\n" +
|
0x49, 0x64, 0x10, 0xb8, 0x10, 0x12, 0x14, 0x0a, 0x0f, 0x53, 0x32, 0x43, 0x55, 0x73, 0x65, 0x72,
|
||||||
"\x10NtfUserOfflineId\x10\xba\x10B\x11Z\x0fcommon/proto/pbb\x06proto3"
|
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,
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
file_msgId_proto_rawDescOnce sync.Once
|
file_msgId_proto_rawDescOnce sync.Once
|
||||||
file_msgId_proto_rawDescData []byte
|
file_msgId_proto_rawDescData = file_msgId_proto_rawDesc
|
||||||
)
|
)
|
||||||
|
|
||||||
func file_msgId_proto_rawDescGZIP() []byte {
|
func file_msgId_proto_rawDescGZIP() []byte {
|
||||||
file_msgId_proto_rawDescOnce.Do(func() {
|
file_msgId_proto_rawDescOnce.Do(func() {
|
||||||
file_msgId_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_msgId_proto_rawDesc), len(file_msgId_proto_rawDesc)))
|
file_msgId_proto_rawDescData = protoimpl.X.CompressGZIP(file_msgId_proto_rawDescData)
|
||||||
})
|
})
|
||||||
return file_msgId_proto_rawDescData
|
return file_msgId_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_msgId_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
var file_msgId_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||||
var file_msgId_proto_goTypes = []any{
|
var file_msgId_proto_goTypes = []interface{}{
|
||||||
(MsgId)(0), // 0: pb.MsgId
|
(MsgId)(0), // 0: pb.MsgId
|
||||||
}
|
}
|
||||||
var file_msgId_proto_depIdxs = []int32{
|
var file_msgId_proto_depIdxs = []int32{
|
||||||
@ -144,7 +150,7 @@ func file_msgId_proto_init() {
|
|||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
File: protoimpl.DescBuilder{
|
File: protoimpl.DescBuilder{
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_msgId_proto_rawDesc), len(file_msgId_proto_rawDesc)),
|
RawDescriptor: file_msgId_proto_rawDesc,
|
||||||
NumEnums: 1,
|
NumEnums: 1,
|
||||||
NumMessages: 0,
|
NumMessages: 0,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
@ -155,6 +161,7 @@ func file_msgId_proto_init() {
|
|||||||
EnumInfos: file_msgId_proto_enumTypes,
|
EnumInfos: file_msgId_proto_enumTypes,
|
||||||
}.Build()
|
}.Build()
|
||||||
File_msgId_proto = out.File
|
File_msgId_proto = out.File
|
||||||
|
file_msgId_proto_rawDesc = nil
|
||||||
file_msgId_proto_goTypes = nil
|
file_msgId_proto_goTypes = nil
|
||||||
file_msgId_proto_depIdxs = nil
|
file_msgId_proto_depIdxs = nil
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.36.6
|
// protoc-gen-go v1.34.1
|
||||||
// protoc v6.31.0
|
// protoc v4.25.2
|
||||||
// source: service.proto
|
// source: service.proto
|
||||||
|
|
||||||
package pb
|
package pb
|
||||||
@ -11,7 +11,6 @@ import (
|
|||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
sync "sync"
|
sync "sync"
|
||||||
unsafe "unsafe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -78,31 +77,32 @@ func (ServiceTypeId) EnumDescriptor() ([]byte, []int) {
|
|||||||
|
|
||||||
var File_service_proto protoreflect.FileDescriptor
|
var File_service_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
const file_service_proto_rawDesc = "" +
|
var file_service_proto_rawDesc = []byte{
|
||||||
"\n" +
|
0x0a, 0x0d, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
|
||||||
"\rservice.proto\x12\x02pb*W\n" +
|
0x02, 0x70, 0x62, 0x2a, 0x57, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79,
|
||||||
"\rServiceTypeId\x12\x0f\n" +
|
0x70, 0x65, 0x49, 0x64, 0x12, 0x0f, 0x0a, 0x0b, 0x53, 0x54, 0x49, 0x5f, 0x55, 0x6e, 0x6b, 0x6e,
|
||||||
"\vSTI_Unknown\x10\x00\x12\f\n" +
|
0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x53, 0x54, 0x49, 0x5f, 0x47, 0x61, 0x74,
|
||||||
"\bSTI_Gate\x10d\x12\r\n" +
|
0x65, 0x10, 0x64, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x54, 0x49, 0x5f, 0x4c, 0x6f, 0x67, 0x69, 0x6e,
|
||||||
"\tSTI_Login\x10e\x12\f\n" +
|
0x10, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x53, 0x54, 0x49, 0x5f, 0x43, 0x68, 0x61, 0x74, 0x10, 0x66,
|
||||||
"\bSTI_Chat\x10f\x12\n" +
|
0x12, 0x0a, 0x0a, 0x06, 0x53, 0x54, 0x49, 0x5f, 0x44, 0x42, 0x10, 0x67, 0x42, 0x11, 0x5a, 0x0f,
|
||||||
"\n" +
|
0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x62, 0x62,
|
||||||
"\x06STI_DB\x10gB\x11Z\x0fcommon/proto/pbb\x06proto3"
|
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
file_service_proto_rawDescOnce sync.Once
|
file_service_proto_rawDescOnce sync.Once
|
||||||
file_service_proto_rawDescData []byte
|
file_service_proto_rawDescData = file_service_proto_rawDesc
|
||||||
)
|
)
|
||||||
|
|
||||||
func file_service_proto_rawDescGZIP() []byte {
|
func file_service_proto_rawDescGZIP() []byte {
|
||||||
file_service_proto_rawDescOnce.Do(func() {
|
file_service_proto_rawDescOnce.Do(func() {
|
||||||
file_service_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_service_proto_rawDesc), len(file_service_proto_rawDesc)))
|
file_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_service_proto_rawDescData)
|
||||||
})
|
})
|
||||||
return file_service_proto_rawDescData
|
return file_service_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
var file_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||||
var file_service_proto_goTypes = []any{
|
var file_service_proto_goTypes = []interface{}{
|
||||||
(ServiceTypeId)(0), // 0: pb.ServiceTypeId
|
(ServiceTypeId)(0), // 0: pb.ServiceTypeId
|
||||||
}
|
}
|
||||||
var file_service_proto_depIdxs = []int32{
|
var file_service_proto_depIdxs = []int32{
|
||||||
@ -122,7 +122,7 @@ func file_service_proto_init() {
|
|||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
File: protoimpl.DescBuilder{
|
File: protoimpl.DescBuilder{
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_service_proto_rawDesc), len(file_service_proto_rawDesc)),
|
RawDescriptor: file_service_proto_rawDesc,
|
||||||
NumEnums: 1,
|
NumEnums: 1,
|
||||||
NumMessages: 0,
|
NumMessages: 0,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
@ -133,6 +133,7 @@ func file_service_proto_init() {
|
|||||||
EnumInfos: file_service_proto_enumTypes,
|
EnumInfos: file_service_proto_enumTypes,
|
||||||
}.Build()
|
}.Build()
|
||||||
File_service_proto = out.File
|
File_service_proto = out.File
|
||||||
|
file_service_proto_rawDesc = nil
|
||||||
file_service_proto_goTypes = nil
|
file_service_proto_goTypes = nil
|
||||||
file_service_proto_depIdxs = nil
|
file_service_proto_depIdxs = nil
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.36.6
|
// protoc-gen-go v1.34.1
|
||||||
// protoc v6.31.0
|
// protoc v4.25.2
|
||||||
// source: user.proto
|
// source: user.proto
|
||||||
|
|
||||||
package pb
|
package pb
|
||||||
@ -11,7 +11,6 @@ import (
|
|||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
sync "sync"
|
sync "sync"
|
||||||
unsafe "unsafe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -23,21 +22,24 @@ const (
|
|||||||
|
|
||||||
// 聊天中显示的玩家基础信息
|
// 聊天中显示的玩家基础信息
|
||||||
type ChatUser struct {
|
type ChatUser struct {
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState
|
||||||
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
|
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
|
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等级
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *ChatUser) Reset() {
|
func (x *ChatUser) Reset() {
|
||||||
*x = ChatUser{}
|
*x = ChatUser{}
|
||||||
mi := &file_user_proto_msgTypes[0]
|
if protoimpl.UnsafeEnabled {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
mi := &file_user_proto_msgTypes[0]
|
||||||
ms.StoreMessageInfo(mi)
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *ChatUser) String() string {
|
func (x *ChatUser) String() string {
|
||||||
@ -48,7 +50,7 @@ func (*ChatUser) ProtoMessage() {}
|
|||||||
|
|
||||||
func (x *ChatUser) ProtoReflect() protoreflect.Message {
|
func (x *ChatUser) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_user_proto_msgTypes[0]
|
mi := &file_user_proto_msgTypes[0]
|
||||||
if x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
@ -100,31 +102,36 @@ func (x *ChatUser) GetVipLevel() string {
|
|||||||
|
|
||||||
var File_user_proto protoreflect.FileDescriptor
|
var File_user_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
const file_user_proto_rawDesc = "" +
|
var file_user_proto_rawDesc = []byte{
|
||||||
"\n" +
|
0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62,
|
||||||
"\n" +
|
0x22, 0x97, 0x01, 0x0a, 0x08, 0x43, 0x68, 0x61, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x17, 0x0a,
|
||||||
"user.proto\x12\x02pb\"\x97\x01\n" +
|
0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06,
|
||||||
"\bChatUser\x12\x17\n" +
|
0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61,
|
||||||
"\auser_id\x18\x01 \x01(\x03R\x06userId\x12\x1a\n" +
|
0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61,
|
||||||
"\bnickname\x18\x02 \x01(\tR\bnickname\x12\x16\n" +
|
0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x03, 0x20, 0x01,
|
||||||
"\x06avatar\x18\x03 \x01(\tR\x06avatar\x12!\n" +
|
0x28, 0x09, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x76,
|
||||||
"\favatar_frame\x18\x04 \x01(\tR\vavatarFrame\x12\x1b\n" +
|
0x61, 0x74, 0x61, 0x72, 0x5f, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09,
|
||||||
"\tvip_level\x18\x05 \x01(\tR\bvipLevelB\x11Z\x0fcommon/proto/pbb\x06proto3"
|
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,
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
file_user_proto_rawDescOnce sync.Once
|
file_user_proto_rawDescOnce sync.Once
|
||||||
file_user_proto_rawDescData []byte
|
file_user_proto_rawDescData = file_user_proto_rawDesc
|
||||||
)
|
)
|
||||||
|
|
||||||
func file_user_proto_rawDescGZIP() []byte {
|
func file_user_proto_rawDescGZIP() []byte {
|
||||||
file_user_proto_rawDescOnce.Do(func() {
|
file_user_proto_rawDescOnce.Do(func() {
|
||||||
file_user_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_user_proto_rawDesc), len(file_user_proto_rawDesc)))
|
file_user_proto_rawDescData = protoimpl.X.CompressGZIP(file_user_proto_rawDescData)
|
||||||
})
|
})
|
||||||
return file_user_proto_rawDescData
|
return file_user_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_user_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
var file_user_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||||
var file_user_proto_goTypes = []any{
|
var file_user_proto_goTypes = []interface{}{
|
||||||
(*ChatUser)(nil), // 0: pb.ChatUser
|
(*ChatUser)(nil), // 0: pb.ChatUser
|
||||||
}
|
}
|
||||||
var file_user_proto_depIdxs = []int32{
|
var file_user_proto_depIdxs = []int32{
|
||||||
@ -140,11 +147,25 @@ func file_user_proto_init() {
|
|||||||
if File_user_proto != nil {
|
if File_user_proto != nil {
|
||||||
return
|
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{}
|
type x struct{}
|
||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
File: protoimpl.DescBuilder{
|
File: protoimpl.DescBuilder{
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_user_proto_rawDesc), len(file_user_proto_rawDesc)),
|
RawDescriptor: file_user_proto_rawDesc,
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 1,
|
NumMessages: 1,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
@ -155,6 +176,7 @@ func file_user_proto_init() {
|
|||||||
MessageInfos: file_user_proto_msgTypes,
|
MessageInfos: file_user_proto_msgTypes,
|
||||||
}.Build()
|
}.Build()
|
||||||
File_user_proto = out.File
|
File_user_proto = out.File
|
||||||
|
file_user_proto_rawDesc = nil
|
||||||
file_user_proto_goTypes = nil
|
file_user_proto_goTypes = nil
|
||||||
file_user_proto_depIdxs = nil
|
file_user_proto_depIdxs = nil
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package topicName
|
package topicName
|
||||||
|
|
||||||
const (
|
const (
|
||||||
//extTopic = ".topic"
|
// extTopic = ".topic"
|
||||||
//extGroup = ".group"
|
// extGroup = ".group"
|
||||||
UserOnline = "user.online.topic"
|
UserOnline = "user.online.topic" // 玩家上线广播
|
||||||
UserOffline = "user.offline.topic"
|
UserOffline = "user.offline.topic" // 玩家下线广播
|
||||||
WorldMessage = "world.msg.topic"
|
WorldMessage = "world.msg.topic" // 全网关广播,所有玩家都能收到该消息
|
||||||
)
|
)
|
||||||
|
31
server/colorgame/cmd/cmd.go
Normal file
31
server/colorgame/cmd/cmd.go
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"game/server/colorgame/config"
|
||||||
|
"game/server/colorgame/model"
|
||||||
|
"game/server/colorgame/server"
|
||||||
|
"github.com/fox/fox/log"
|
||||||
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
func initRepo() {
|
||||||
|
model.InitRedis()
|
||||||
|
}
|
||||||
|
|
||||||
|
func Run(GitCommit, GitBranch, BuildDate string) {
|
||||||
|
config.InitLog()
|
||||||
|
config.LoadConfig(GitCommit, GitBranch, BuildDate)
|
||||||
|
log.Info(fmt.Sprintf("版本分支:%v,hash值:%v,编译时间:%v", GitBranch, GitCommit, BuildDate))
|
||||||
|
initRepo()
|
||||||
|
|
||||||
|
server.Init()
|
||||||
|
// 截获 SIGINT 和 SIGTERM 信号
|
||||||
|
c := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(c, syscall.SIGINT, syscall.SIGTERM)
|
||||||
|
sig := <-c
|
||||||
|
server.Stop()
|
||||||
|
log.Info(fmt.Sprintf("received %s, initiating shutdown...", sig))
|
||||||
|
}
|
38
server/colorgame/config/config.go
Normal file
38
server/colorgame/config/config.go
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"game/common/config"
|
||||||
|
"game/common/constant"
|
||||||
|
"github.com/fox/fox/db"
|
||||||
|
"github.com/fox/fox/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Command *config.Command
|
||||||
|
var Cfg *config.Common[LoginConfig]
|
||||||
|
|
||||||
|
type LoginConfig struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func InitLog() {
|
||||||
|
log.Open("./log/login.log", log.DebugL)
|
||||||
|
log.Info("")
|
||||||
|
log.Info("")
|
||||||
|
log.Info("")
|
||||||
|
log.Info("-----init log success-----")
|
||||||
|
}
|
||||||
|
|
||||||
|
func LoadConfig(GitCommit, GitBranch, BuildDate string) {
|
||||||
|
Command = config.ParseCommand()
|
||||||
|
rdb, err := db.InitRedis(Command.RedisPassword, Command.RedisHost, Command.RedisPort, constant.Redis0Config)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer func() { _ = rdb.Close() }()
|
||||||
|
Cfg, err = config.LoadCommonConfig[LoginConfig](rdb, GitCommit, GitBranch, BuildDate)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.DebugF("load common config success")
|
||||||
|
}
|
24
server/colorgame/main.go
Normal file
24
server/colorgame/main.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"game/server/colorgame/cmd"
|
||||||
|
"github.com/fox/fox/ksync"
|
||||||
|
"github.com/fox/fox/log"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
GitCommit = "unknown"
|
||||||
|
GitBranch = "unknown"
|
||||||
|
BuildDate = "unknown"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
tm, err := time.Parse("20060102150405", BuildDate)
|
||||||
|
if err == nil {
|
||||||
|
BuildDate = tm.Format("2006-01-02 15:04:05")
|
||||||
|
}
|
||||||
|
ksync.RunSafe(func() {
|
||||||
|
cmd.Run(GitBranch, GitCommit, BuildDate)
|
||||||
|
}, func() { log.ErrorF("reset run") })
|
||||||
|
}
|
26
server/colorgame/model/db.go
Normal file
26
server/colorgame/model/db.go
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"game/common/constant"
|
||||||
|
"game/common/utils"
|
||||||
|
"game/server/colorgame/config"
|
||||||
|
"github.com/fox/fox/db"
|
||||||
|
"github.com/fox/fox/log"
|
||||||
|
"github.com/go-redis/redis/v8"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
UserBindServiceRedis *redis.Client
|
||||||
|
)
|
||||||
|
|
||||||
|
func InitRedis() {
|
||||||
|
log.Debug("init redis")
|
||||||
|
var err error
|
||||||
|
cfg := &config.Cfg.Redis
|
||||||
|
UserBindServiceRedis, err = db.InitRedis(cfg.Password, cfg.Host, cfg.Port, constant.Redis3UserBindService)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
utils.AutoSetRedisPool(UserBindServiceRedis)
|
||||||
|
}
|
152
server/colorgame/model/userAccount.go
Normal file
152
server/colorgame/model/userAccount.go
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
//import (
|
||||||
|
// "errors"
|
||||||
|
// "github.com/fox/fox/log"
|
||||||
|
// "golang.org/x/crypto/bcrypt"
|
||||||
|
// "gorm.io/gorm"
|
||||||
|
// "time"
|
||||||
|
//)
|
||||||
|
//
|
||||||
|
//const (
|
||||||
|
// AccountNormal = 1 // 正常
|
||||||
|
// AccountFrozen = 2 // 冻结
|
||||||
|
// AccountBanned = 3 // 封禁
|
||||||
|
//)
|
||||||
|
//
|
||||||
|
//// 玩家账户表
|
||||||
|
//type UserAccount struct {
|
||||||
|
// gorm.Model
|
||||||
|
// Username string `gorm:"type:varchar(32);uniqueIndex;not null"` // 用户名
|
||||||
|
// Password string `gorm:"type:varchar(255);not null"` // 密码哈希
|
||||||
|
// Email string `gorm:"type:varchar(100)"` // 邮箱(可选)
|
||||||
|
// Phone string `gorm:"type:varchar(20)"` // 手机号(可选)
|
||||||
|
// DeviceID string `gorm:"type:varchar(64);index"` // 设备ID
|
||||||
|
// LastLoginIP string `gorm:"type:varchar(45)"` // 最后登录IP(支持IPv6)
|
||||||
|
// LastLoginTime time.Time // 最后登录时间
|
||||||
|
// Status int `gorm:"type:tinyint;default:1"` // 账号状态 1-正常 2-冻结 3-封禁
|
||||||
|
// RegisterIP string `gorm:"type:varchar(45)"` // 注册IP
|
||||||
|
// RegisterTime time.Time `gorm:"type:TIMESTAMP;default:CURRENT_TIMESTAMP"` // 注册时间
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//// 玩家登录记录表
|
||||||
|
//type UserLoginLog struct {
|
||||||
|
// gorm.Model
|
||||||
|
// PlayerID uint `gorm:"index"` // 关联玩家ID
|
||||||
|
// LoginIP string `gorm:"type:varchar(45);not null"` // 登录IP
|
||||||
|
// LoginTime time.Time `gorm:"type:TIMESTAMP;default:CURRENT_TIMESTAMP"` // 登录时间
|
||||||
|
// DeviceInfo string `gorm:"type:varchar(255)"` // 设备信息(JSON格式)
|
||||||
|
// LoginResult bool // 登录结果 true-成功 false-失败
|
||||||
|
// FailReason string `gorm:"type:varchar(100)"` // 失败原因
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//type UserLoginOp struct {
|
||||||
|
// db *gorm.DB
|
||||||
|
// logDb *gorm.DB
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func NewUserLoginOp() *UserLoginOp {
|
||||||
|
// return &UserLoginOp{db: UserDB, logDb: LogDB}
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//var (
|
||||||
|
// ErrUserOrPassword = errors.New("user or password was error")
|
||||||
|
// ErrAccountFrozen = errors.New("account frozen")
|
||||||
|
// ErrAccountBanned = errors.New("account banned")
|
||||||
|
//)
|
||||||
|
//
|
||||||
|
//func (s *UserLoginOp) Login(username, password, ip, deviceID string) (*UserAccount, error) {
|
||||||
|
// var user UserAccount
|
||||||
|
// err := s.db.Where("username = ?", username).First(&user).Error
|
||||||
|
// if err != nil {
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
// // 验证密码
|
||||||
|
// if err = bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(password)); err != nil {
|
||||||
|
// s.recordLoginLog(user.ID, ip, deviceID, false, ErrUserOrPassword.Error())
|
||||||
|
// return nil, ErrUserOrPassword
|
||||||
|
// }
|
||||||
|
// // 检查账号状态
|
||||||
|
// switch user.Status {
|
||||||
|
// case AccountNormal:
|
||||||
|
//
|
||||||
|
// case AccountFrozen:
|
||||||
|
// s.recordLoginLog(user.ID, ip, deviceID, false, ErrAccountFrozen.Error())
|
||||||
|
// return nil, ErrAccountFrozen
|
||||||
|
// case AccountBanned:
|
||||||
|
// s.recordLoginLog(user.ID, ip, deviceID, false, ErrAccountBanned.Error())
|
||||||
|
// return nil, ErrAccountBanned
|
||||||
|
// }
|
||||||
|
// // 更新最后登录信息
|
||||||
|
// user.LastLoginIP = ip
|
||||||
|
// user.LastLoginTime = time.Now()
|
||||||
|
// _ = s.db.Save(&user).Error
|
||||||
|
//
|
||||||
|
// // 记录成功登录日志
|
||||||
|
// s.recordLoginLog(user.ID, ip, deviceID, true, "")
|
||||||
|
//
|
||||||
|
// // 6. 生成访问令牌
|
||||||
|
// token, err := generateToken(user.ID, user.Username)
|
||||||
|
// if err != nil {
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
// user.Password = token
|
||||||
|
// return &user, err
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//// 注册新用户
|
||||||
|
//func (s *UserLoginOp) RegisterNewUser(username, password, ip, deviceID string) (*UserAccount, error) {
|
||||||
|
// // 密码加密
|
||||||
|
// hashedPassword, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
|
||||||
|
// if err != nil {
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
// user := UserAccount{
|
||||||
|
// Username: username,
|
||||||
|
// Password: string(hashedPassword),
|
||||||
|
// DeviceID: deviceID,
|
||||||
|
// RegisterIP: ip,
|
||||||
|
// Status: 1,
|
||||||
|
// LastLoginIP: ip,
|
||||||
|
// LastLoginTime: time.Now(),
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if err := s.db.Create(&user).Error; err != nil {
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// s.recordLoginLog(user.ID, ip, deviceID, true, "")
|
||||||
|
//
|
||||||
|
// // 生成访问令牌
|
||||||
|
// token, err := generateToken(user.ID, user.Username)
|
||||||
|
// if err != nil {
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
// user.Password = token
|
||||||
|
//
|
||||||
|
// return &user, nil
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//// 记录登录日志
|
||||||
|
//func (s *UserLoginOp) recordLoginLog(userID uint, ip, deviceID string, success bool, failReason string) {
|
||||||
|
// logEntry := UserLoginLog{
|
||||||
|
// PlayerID: userID,
|
||||||
|
// LoginIP: ip,
|
||||||
|
// DeviceInfo: deviceID,
|
||||||
|
// LoginResult: success,
|
||||||
|
// FailReason: failReason,
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if err := s.logDb.Create(&logEntry).Error; err != nil {
|
||||||
|
// log.ErrorF("记录登录日志失败: %v", err)
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//// 生成JWT令牌(简化版)
|
||||||
|
//func generateToken(userID uint, username string) (string, error) {
|
||||||
|
// _ = userID
|
||||||
|
// _ = username
|
||||||
|
// // 这里应该使用JWT库生成实际令牌
|
||||||
|
// // 简化实现,实际项目中请使用安全的JWT实现
|
||||||
|
// return "generated-token-placeholder", nil
|
||||||
|
//}
|
156
server/colorgame/server/processor.go
Normal file
156
server/colorgame/server/processor.go
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"game/common/model/user"
|
||||||
|
"game/common/proto/pb"
|
||||||
|
"game/common/rpcName"
|
||||||
|
"game/common/utils"
|
||||||
|
"github.com/fox/fox/etcd"
|
||||||
|
"github.com/fox/fox/ipb"
|
||||||
|
"github.com/fox/fox/ksync"
|
||||||
|
"github.com/fox/fox/log"
|
||||||
|
"github.com/fox/fox/processor"
|
||||||
|
"github.com/fox/fox/service"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
timeout = time.Second * 30
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s *LoginService) 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) {
|
||||||
|
var err error
|
||||||
|
node, err = s.bindService.RandServiceNode(pb.ServiceTypeId_STI_DB)
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorF(s.Log("not find db service.err:%s ", err.Error()))
|
||||||
|
return nil, pb.ErrCode_SystemErr, node
|
||||||
|
}
|
||||||
|
if req.Version < "20250601123030" {
|
||||||
|
return nil, pb.ErrCode_VersionTooLow, node
|
||||||
|
}
|
||||||
|
us = &user.UserAccount{
|
||||||
|
Username: req.Username,
|
||||||
|
Password: req.Password,
|
||||||
|
DeviceID: req.DeviceId,
|
||||||
|
LastLoginIP: req.Ip,
|
||||||
|
}
|
||||||
|
rpcMsg := ipb.MakeRpcMsg[user.UserAccount](rpcName.GetUserAccount, 0, us)
|
||||||
|
rspMsg, err := s.Call(service.RpcTopicEx(node.Name), timeout, rpcMsg)
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorF(s.Log("call rpc:%v err:%s ", rpcMsg.RpcMsgId, err.Error()))
|
||||||
|
return nil, pb.ErrCode_SystemErr, node
|
||||||
|
}
|
||||||
|
_ = json.Unmarshal(rspMsg.Msg, us)
|
||||||
|
//log.DebugF("收到rpc:%v返回数据:%v", rpcName.GetUserAccount, string(rspMsg.Msg))
|
||||||
|
if us.ID == 0 {
|
||||||
|
// 没有帐号,创建帐号
|
||||||
|
us = &user.UserAccount{
|
||||||
|
Username: req.Username,
|
||||||
|
Password: req.Password,
|
||||||
|
DeviceID: req.DeviceId,
|
||||||
|
LastLoginIP: req.Ip,
|
||||||
|
LastLoginTime: time.Now(),
|
||||||
|
RegisterIP: req.Ip,
|
||||||
|
RegisterTime: time.Now(),
|
||||||
|
}
|
||||||
|
rpcMsg = ipb.MakeRpcMsg[user.UserAccount](rpcName.CreateUserAccount, 0, us)
|
||||||
|
rspMsg, err = s.Call(service.RpcTopicEx(node.Name), timeout, rpcMsg)
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorF(s.Log("call rpc:%v err:%s ", rpcMsg.RpcMsgId, err.Error()))
|
||||||
|
return nil, pb.ErrCode_SystemErr, node
|
||||||
|
}
|
||||||
|
_ = json.Unmarshal(rspMsg.Msg, us)
|
||||||
|
if us.ID == 0 {
|
||||||
|
log.ErrorF(s.Log("call rpc:%v err", rpcMsg.RpcMsgId))
|
||||||
|
return nil, pb.ErrCode_SystemErr, node
|
||||||
|
}
|
||||||
|
log.DebugF("收到rcp:%v返回数据:%v", rpcName.CreateUserAccount, string(rspMsg.Msg))
|
||||||
|
}
|
||||||
|
if !utils.CheckPassword(req.Password, us.Password) {
|
||||||
|
log.ErrorF(s.Log("用户密码:%v 数据库中密码:%v", req.Password, us.Password))
|
||||||
|
return nil, pb.ErrCode_LoginUserOrPwdErr, node
|
||||||
|
}
|
||||||
|
switch us.Status {
|
||||||
|
case user.AccountFrozen:
|
||||||
|
return nil, pb.ErrCode_AccountFrozen, node
|
||||||
|
case user.AccountBanned:
|
||||||
|
return nil, pb.ErrCode_AccountBanned, node
|
||||||
|
default:
|
||||||
|
return us, pb.ErrCode_OK, node
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 生成JWT令牌(简化版)
|
||||||
|
func generateToken(userID int64, username string) (string, error) {
|
||||||
|
_ = userID
|
||||||
|
_ = username
|
||||||
|
// 这里应该使用JWT库生成实际令牌
|
||||||
|
// 简化实现,实际项目中请使用安全的JWT实现
|
||||||
|
return "generated-token-placeholder", nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取用户数据,如果没有则创建
|
||||||
|
func (s *LoginService) getUser(accountId int64, tName string) (*user.User, pb.ErrCode) {
|
||||||
|
us := &user.User{
|
||||||
|
AccountId: accountId,
|
||||||
|
}
|
||||||
|
rpcMsg := ipb.MakeRpcMsg[user.User](rpcName.GetUserByAccountId, 0, us)
|
||||||
|
rsp, err := s.Call(service.RpcTopicEx(tName), timeout, rpcMsg)
|
||||||
|
if err != nil {
|
||||||
|
log.ErrorF(s.Log("call rpc:%v err:%s", rpcMsg.RpcMsgId, err.Error()))
|
||||||
|
return nil, pb.ErrCode_SystemErr
|
||||||
|
}
|
||||||
|
_ = json.Unmarshal(rsp.Msg, us)
|
||||||
|
if us.ID == 0 {
|
||||||
|
log.ErrorF(s.Log("call rpc:%v return:%v", rpcMsg.RpcMsgId, string(rsp.Msg)))
|
||||||
|
return us, pb.ErrCode_SystemErr
|
||||||
|
}
|
||||||
|
return us, pb.ErrCode_OK
|
||||||
|
}
|
||||||
|
|
||||||
|
// 登录或注册
|
||||||
|
func (s *LoginService) onLoginOrRegister(iMsg *ipb.InternalMsg, req *pb.C2SUserLogin) {
|
||||||
|
ksync.GoSafe(func() {
|
||||||
|
account, code, node := s.checkLoginOrRegister(req)
|
||||||
|
userId := int64(0)
|
||||||
|
rsp := &pb.S2CUserLogin{Code: code}
|
||||||
|
if account != nil && code == pb.ErrCode_OK {
|
||||||
|
// 拉取用户数据
|
||||||
|
us := &user.User{}
|
||||||
|
us, code = s.getUser(userId, req.Username)
|
||||||
|
if code == pb.ErrCode_OK {
|
||||||
|
rsp.UserId = us.ID
|
||||||
|
rsp.Token, _ = generateToken(account.ID, account.Username)
|
||||||
|
userId = rsp.UserId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s.SendServiceMsg(service.TopicEx(iMsg.ServiceName), iMsg.ConnId, userId, int32(pb.MsgId_S2CUserLoginId), rsp)
|
||||||
|
|
||||||
|
if account != nil && account.ID > 0 {
|
||||||
|
loginLog := &user.UserLoginLog{
|
||||||
|
AccountID: account.ID,
|
||||||
|
LoginIP: req.Ip,
|
||||||
|
LoginTime: time.Now(),
|
||||||
|
DeviceInfo: req.DeviceId,
|
||||||
|
LoginResult: code == pb.ErrCode_OK,
|
||||||
|
FailReason: code.String(),
|
||||||
|
}
|
||||||
|
switch code {
|
||||||
|
case pb.ErrCode_LoginUserOrPwdErr, pb.ErrCode_OK:
|
||||||
|
rpcMsg := ipb.MakeRpcMsg[user.UserLoginLog](rpcName.LogUserAccountLogin, 0, loginLog)
|
||||||
|
ksync.GoSafe(func() {
|
||||||
|
_, _ = s.Call(service.RpcTopicEx(node.Name), timeout, rpcMsg)
|
||||||
|
}, nil)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}, nil)
|
||||||
|
}
|
116
server/colorgame/server/service.go
Normal file
116
server/colorgame/server/service.go
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"game/common/proto/pb"
|
||||||
|
"game/common/serviceName"
|
||||||
|
"game/common/userBindService"
|
||||||
|
"game/server/colorgame/config"
|
||||||
|
"game/server/colorgame/model"
|
||||||
|
"github.com/fox/fox/ipb"
|
||||||
|
"github.com/fox/fox/log"
|
||||||
|
"github.com/fox/fox/processor"
|
||||||
|
"github.com/fox/fox/service"
|
||||||
|
"github.com/golang/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Login []*LoginService
|
||||||
|
|
||||||
|
type LoginService struct {
|
||||||
|
*service.NatsService
|
||||||
|
processor *processor.Processor
|
||||||
|
bindService *userBindService.UserBindService
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Stop() {
|
||||||
|
for _, srv := range Login {
|
||||||
|
log.DebugF("notify stop service %v", srv.Name())
|
||||||
|
srv.NotifyStop()
|
||||||
|
}
|
||||||
|
for _, srv := range Login {
|
||||||
|
srv.WaitStop()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newLoginService(serviceId int) *LoginService {
|
||||||
|
var err error
|
||||||
|
s := new(LoginService)
|
||||||
|
|
||||||
|
sName := fmt.Sprintf("%v-%d", serviceName.Login, serviceId)
|
||||||
|
if s.NatsService, err = service.NewNatsService(&service.InitNatsServiceParams{
|
||||||
|
EtcdAddress: config.Cfg.Etcd.Address,
|
||||||
|
EtcdUsername: "",
|
||||||
|
EtcdPassword: "",
|
||||||
|
NatsAddress: config.Cfg.Nats.Address,
|
||||||
|
ServiceType: serviceName.Login,
|
||||||
|
ServiceName: sName,
|
||||||
|
OnFunc: s,
|
||||||
|
TypeId: int(pb.ServiceTypeId_STI_Login),
|
||||||
|
Version: config.Cfg.BuildDate,
|
||||||
|
}); err != nil {
|
||||||
|
log.Fatal(err.Error())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
s.bindService = userBindService.NewUserBindService(model.UserBindServiceRedis, s.ServiceEtcd())
|
||||||
|
s.processor = processor.NewProcessor()
|
||||||
|
s.initProcessor()
|
||||||
|
s.OnInit()
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *LoginService) OnInit() {
|
||||||
|
// if err := s.NatsService.QueueSubscribe(service.GroupTopic(s), service.GroupQueue(s)); err != nil {
|
||||||
|
// log.Error(err.Error())
|
||||||
|
// }
|
||||||
|
s.NatsService.Run()
|
||||||
|
log.Debug("onInit")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *LoginService) CanStop() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *LoginService) OnStop() {
|
||||||
|
s.NatsService.OnStop()
|
||||||
|
log.Debug("OnStop")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理其它服发送过来的消息
|
||||||
|
func (s *LoginService) OnMessage(data []byte) error {
|
||||||
|
var iMsg = &ipb.InternalMsg{}
|
||||||
|
var err error
|
||||||
|
if err = proto.Unmarshal(data, iMsg); err != nil {
|
||||||
|
log.Error(err.Error())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if req, err := s.processor.Unmarshal(iMsg.MsgId, iMsg.Msg); err == nil {
|
||||||
|
err = s.processor.Dispatch(iMsg.MsgId, iMsg, req)
|
||||||
|
} else {
|
||||||
|
log.Error(err.Error())
|
||||||
|
}
|
||||||
|
log.Debug(s.Log("received message:%v", iMsg.MsgId))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 向内部服务发送消息
|
||||||
|
func (s *LoginService) 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) {
|
||||||
|
data, _ := proto.Marshal(msg)
|
||||||
|
s.SendServiceData(topic, connId, userId, msgId, data)
|
||||||
|
}
|
@ -2,6 +2,7 @@ package model
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"game/common/constant"
|
"game/common/constant"
|
||||||
|
"game/common/utils"
|
||||||
"game/server/login/config"
|
"game/server/login/config"
|
||||||
"github.com/fox/fox/db"
|
"github.com/fox/fox/db"
|
||||||
"github.com/fox/fox/log"
|
"github.com/fox/fox/log"
|
||||||
@ -10,8 +11,8 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
UserBindServiceRedis *redis.Client
|
UserBindServiceRedis *redis.Client
|
||||||
//UserDB *gorm.DB
|
// UserDB *gorm.DB
|
||||||
//LogDB *gorm.DB
|
// LogDB *gorm.DB
|
||||||
)
|
)
|
||||||
|
|
||||||
func InitRedis() {
|
func InitRedis() {
|
||||||
@ -23,10 +24,11 @@ func InitRedis() {
|
|||||||
log.Fatal(err.Error())
|
log.Fatal(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
utils.AutoSetRedisPool(UserBindServiceRedis)
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
//func InitDb() {
|
// func InitDb() {
|
||||||
// log.Debug("init db")
|
// log.Debug("init db")
|
||||||
// var err error
|
// var err error
|
||||||
// cfg := &config.Cfg.Mysql
|
// cfg := &config.Cfg.Mysql
|
||||||
@ -57,4 +59,4 @@ func InitRedis() {
|
|||||||
// log.Fatal(err.Error())
|
// log.Fatal(err.Error())
|
||||||
// return
|
// return
|
||||||
// }
|
// }
|
||||||
//}
|
// }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user