修改bug

This commit is contained in:
liuxiaobo 2025-06-15 22:03:16 +08:00
parent 3a6201381e
commit 5265c0a1e2
6 changed files with 79 additions and 37 deletions

View File

@ -4,11 +4,12 @@ option go_package = "common/proto/pb";
import "code.proto"; import "code.proto";
import "user.proto"; import "user.proto";
import "service.proto";
// //
message ReqMatchRoom message ReqMatchRoom
{ {
int32 gameId = 1; // id ServiceTypeId gameId = 1; // id
int32 roomType = 2; // , int32 roomType = 2; // ,
} }
@ -22,7 +23,7 @@ message RspMatchRoom
} }
ErrCode code = 1; ErrCode code = 1;
int32 gameId = 2; // id ServiceTypeId gameId = 2; // id
int32 roomType = 3; // , int32 roomType = 3; // ,
GameUser User = 4; // GameUser User = 4; //

View File

@ -24,8 +24,8 @@ const (
// 房间匹配 // 房间匹配
type ReqMatchRoom struct { type ReqMatchRoom struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
GameId int32 `protobuf:"varint,1,opt,name=gameId,proto3" json:"gameId,omitempty"` // 玩法id GameId ServiceTypeId `protobuf:"varint,1,opt,name=gameId,proto3,enum=pb.ServiceTypeId" json:"gameId,omitempty"` // 玩法id
RoomType int32 `protobuf:"varint,2,opt,name=roomType,proto3" json:"roomType,omitempty"` // 房间类型,低级,中级,高级等 RoomType int32 `protobuf:"varint,2,opt,name=roomType,proto3" json:"roomType,omitempty"` // 房间类型,低级,中级,高级等
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
@ -60,11 +60,11 @@ func (*ReqMatchRoom) Descriptor() ([]byte, []int) {
return file_match_proto_rawDescGZIP(), []int{0} return file_match_proto_rawDescGZIP(), []int{0}
} }
func (x *ReqMatchRoom) GetGameId() int32 { func (x *ReqMatchRoom) GetGameId() ServiceTypeId {
if x != nil { if x != nil {
return x.GameId return x.GameId
} }
return 0 return ServiceTypeId_STI_Unknown
} }
func (x *ReqMatchRoom) GetRoomType() int32 { func (x *ReqMatchRoom) GetRoomType() int32 {
@ -78,10 +78,10 @@ func (x *ReqMatchRoom) GetRoomType() int32 {
type RspMatchRoom struct { type RspMatchRoom struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
Code ErrCode `protobuf:"varint,1,opt,name=code,proto3,enum=pb.ErrCode" json:"code,omitempty"` Code ErrCode `protobuf:"varint,1,opt,name=code,proto3,enum=pb.ErrCode" json:"code,omitempty"`
GameId int32 `protobuf:"varint,2,opt,name=gameId,proto3" json:"gameId,omitempty"` // 玩法id GameId ServiceTypeId `protobuf:"varint,2,opt,name=gameId,proto3,enum=pb.ServiceTypeId" json:"gameId,omitempty"` // 玩法id
RoomType int32 `protobuf:"varint,3,opt,name=roomType,proto3" json:"roomType,omitempty"` // 房间类型,低级,中级,高级等 RoomType int32 `protobuf:"varint,3,opt,name=roomType,proto3" json:"roomType,omitempty"` // 房间类型,低级,中级,高级等
User *GameUser `protobuf:"bytes,4,opt,name=User,proto3" json:"User,omitempty"` // 玩家数据 User *GameUser `protobuf:"bytes,4,opt,name=User,proto3" json:"User,omitempty"` // 玩家数据
ColorInfo *RspMatchRoom_ColorInfo `protobuf:"bytes,20,opt,name=colorInfo,proto3" json:"colorInfo,omitempty"` // color玩法配置信息 ColorInfo *RspMatchRoom_ColorInfo `protobuf:"bytes,20,opt,name=colorInfo,proto3" json:"colorInfo,omitempty"` // color玩法配置信息
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
@ -123,11 +123,11 @@ func (x *RspMatchRoom) GetCode() ErrCode {
return ErrCode_OK return ErrCode_OK
} }
func (x *RspMatchRoom) GetGameId() int32 { func (x *RspMatchRoom) GetGameId() ServiceTypeId {
if x != nil { if x != nil {
return x.GameId return x.GameId
} }
return 0 return ServiceTypeId_STI_Unknown
} }
func (x *RspMatchRoom) GetRoomType() int32 { func (x *RspMatchRoom) GetRoomType() int32 {
@ -238,13 +238,13 @@ const file_match_proto_rawDesc = "" +
"\n" + "\n" +
"\vmatch.proto\x12\x02pb\x1a\n" + "\vmatch.proto\x12\x02pb\x1a\n" +
"code.proto\x1a\n" + "code.proto\x1a\n" +
"user.proto\"B\n" + "user.proto\x1a\rservice.proto\"U\n" +
"\fReqMatchRoom\x12\x16\n" + "\fReqMatchRoom\x12)\n" +
"\x06gameId\x18\x01 \x01(\x05R\x06gameId\x12\x1a\n" + "\x06gameId\x18\x01 \x01(\x0e2\x11.pb.ServiceTypeIdR\x06gameId\x12\x1a\n" +
"\broomType\x18\x02 \x01(\x05R\broomType\"\xcc\x01\n" + "\broomType\x18\x02 \x01(\x05R\broomType\"\xdf\x01\n" +
"\fRspMatchRoom\x12\x1f\n" + "\fRspMatchRoom\x12\x1f\n" +
"\x04code\x18\x01 \x01(\x0e2\v.pb.ErrCodeR\x04code\x12\x16\n" + "\x04code\x18\x01 \x01(\x0e2\v.pb.ErrCodeR\x04code\x12)\n" +
"\x06gameId\x18\x02 \x01(\x05R\x06gameId\x12\x1a\n" + "\x06gameId\x18\x02 \x01(\x0e2\x11.pb.ServiceTypeIdR\x06gameId\x12\x1a\n" +
"\broomType\x18\x03 \x01(\x05R\broomType\x12 \n" + "\broomType\x18\x03 \x01(\x05R\broomType\x12 \n" +
"\x04User\x18\x04 \x01(\v2\f.pb.GameUserR\x04User\x128\n" + "\x04User\x18\x04 \x01(\v2\f.pb.GameUserR\x04User\x128\n" +
"\tcolorInfo\x18\x14 \x01(\v2\x1a.pb.RspMatchRoom.ColorInfoR\tcolorInfo\x1a\v\n" + "\tcolorInfo\x18\x14 \x01(\v2\x1a.pb.RspMatchRoom.ColorInfoR\tcolorInfo\x1a\v\n" +
@ -270,19 +270,22 @@ var file_match_proto_goTypes = []any{
(*RspMatchRoom)(nil), // 1: pb.RspMatchRoom (*RspMatchRoom)(nil), // 1: pb.RspMatchRoom
(*NotifyUserEnterRoom)(nil), // 2: pb.NotifyUserEnterRoom (*NotifyUserEnterRoom)(nil), // 2: pb.NotifyUserEnterRoom
(*RspMatchRoom_ColorInfo)(nil), // 3: pb.RspMatchRoom.ColorInfo (*RspMatchRoom_ColorInfo)(nil), // 3: pb.RspMatchRoom.ColorInfo
(ErrCode)(0), // 4: pb.ErrCode (ServiceTypeId)(0), // 4: pb.ServiceTypeId
(*GameUser)(nil), // 5: pb.GameUser (ErrCode)(0), // 5: pb.ErrCode
(*GameUser)(nil), // 6: pb.GameUser
} }
var file_match_proto_depIdxs = []int32{ var file_match_proto_depIdxs = []int32{
4, // 0: pb.RspMatchRoom.code:type_name -> pb.ErrCode 4, // 0: pb.ReqMatchRoom.gameId:type_name -> pb.ServiceTypeId
5, // 1: pb.RspMatchRoom.User:type_name -> pb.GameUser 5, // 1: pb.RspMatchRoom.code:type_name -> pb.ErrCode
3, // 2: pb.RspMatchRoom.colorInfo:type_name -> pb.RspMatchRoom.ColorInfo 4, // 2: pb.RspMatchRoom.gameId:type_name -> pb.ServiceTypeId
5, // 3: pb.NotifyUserEnterRoom.User:type_name -> pb.GameUser 6, // 3: pb.RspMatchRoom.User:type_name -> pb.GameUser
4, // [4:4] is the sub-list for method output_type 3, // 4: pb.RspMatchRoom.colorInfo:type_name -> pb.RspMatchRoom.ColorInfo
4, // [4:4] is the sub-list for method input_type 6, // 5: pb.NotifyUserEnterRoom.User:type_name -> pb.GameUser
4, // [4:4] is the sub-list for extension type_name 6, // [6:6] is the sub-list for method output_type
4, // [4:4] is the sub-list for extension extendee 6, // [6:6] is the sub-list for method input_type
0, // [0:4] is the sub-list for field type_name 6, // [6:6] is the sub-list for extension type_name
6, // [6:6] is the sub-list for extension extendee
0, // [0:6] is the sub-list for field type_name
} }
func init() { file_match_proto_init() } func init() { file_match_proto_init() }
@ -292,6 +295,7 @@ func file_match_proto_init() {
} }
file_code_proto_init() file_code_proto_init()
file_user_proto_init() file_user_proto_init()
file_service_proto_init()
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{ File: protoimpl.DescBuilder{

View File

@ -19,10 +19,10 @@ func (s *ClientService) chat() {
// 收到登陆成功消息,判断是否顶号 // 收到登陆成功消息,判断是否顶号
func (s *ClientService) onChat(cMsg *pb.ClientMsg, msg *pb.RspUserLogin) { func (s *ClientService) onChat(cMsg *pb.ClientMsg, msg *pb.RspUserLogin) {
if msg.Code != pb.ErrCode_OK { if msg.Code != pb.ErrCode_OK {
log.ErrorF("login error: %v", msg.Code) log.ErrorF("reqLogin error: %v", msg.Code)
return return
} }
_ = cMsg _ = cMsg
s.userId = msg.UserId s.userId = msg.UserId
log.DebugF("user:%v id:%v login success", s.username, msg.UserId) log.DebugF("user:%v id:%v reqLogin success", s.username, msg.UserId)
} }

View File

@ -0,0 +1,24 @@
package server
//func (s *ClientService) reqLogin() {
// log.DebugF("user:%v ready reqLogin", s.username)
// s.SendMsg(pb.ServiceTypeId_STI_Login, int32(pb.MsgId_ReqUserLoginId), &pb.ReqUserLogin{
// Username: s.username,
// Password: s.password,
// Ip: "",
// DeviceId: "",
// Version: "20250604123030",
// })
//}
//
//// 收到登陆成功消息,判断是否顶号
//func (s *ClientService) onLogin(cMsg *pb.ClientMsg, msg *pb.RspUserLogin) {
// if msg.Code != pb.ErrCode_OK {
// log.ErrorF("reqLogin error:%v :%v", msg.Code, msg.Code.String())
// return
// }
// _ = cMsg
// s.userId = msg.UserId
// s.client.SetUid(msg.UserId)
// log.DebugF("user:%v id:%v reqLogin success", s.username, msg.UserId)
//}

View File

@ -5,8 +5,8 @@ import (
"github.com/fox/fox/log" "github.com/fox/fox/log"
) )
func (s *ClientService) login() { func (s *ClientService) reqLogin() {
log.DebugF("user:%v ready login", s.username) log.DebugF("user:%v ready reqLogin", s.username)
s.SendMsg(pb.ServiceTypeId_STI_Login, int32(pb.MsgId_ReqUserLoginId), &pb.ReqUserLogin{ s.SendMsg(pb.ServiceTypeId_STI_Login, int32(pb.MsgId_ReqUserLoginId), &pb.ReqUserLogin{
Username: s.username, Username: s.username,
Password: s.password, Password: s.password,
@ -19,11 +19,19 @@ func (s *ClientService) login() {
// 收到登陆成功消息,判断是否顶号 // 收到登陆成功消息,判断是否顶号
func (s *ClientService) onLogin(cMsg *pb.ClientMsg, msg *pb.RspUserLogin) { func (s *ClientService) onLogin(cMsg *pb.ClientMsg, msg *pb.RspUserLogin) {
if msg.Code != pb.ErrCode_OK { if msg.Code != pb.ErrCode_OK {
log.ErrorF("login error:%v :%v", msg.Code, msg.Code.String()) log.ErrorF("reqLogin error:%v :%v", msg.Code, msg.Code.String())
return return
} }
_ = cMsg _ = cMsg
s.userId = msg.UserId s.userId = msg.UserId
s.client.SetUid(msg.UserId) s.client.SetUid(msg.UserId)
log.DebugF("user:%v id:%v login success", s.username, msg.UserId) log.DebugF("user:%v id:%v reqLogin success", s.username, msg.UserId)
}
func (s *ClientService) reqMatchRoom() {
log.DebugF(s.Log("ready reqMatch"))
s.SendMsg(pb.ServiceTypeId_STI_Match, int32(pb.MsgId_ReqMatchRoomId), &pb.ReqMatchRoom{
GameId: pb.ServiceTypeId_STI_ColorGame,
RoomType: 0,
})
} }

View File

@ -60,8 +60,8 @@ func newClientService(serviceId int) *ClientService {
} }
func (s *ClientService) loopLoginHour() { func (s *ClientService) loopLoginHour() {
s.login() s.reqLogin()
time.AfterFunc(5*time.Minute, s.loopLoginHour) //time.AfterFunc(5*time.Minute, s.loopLoginHour)
} }
func (s *ClientService) OnInit() { func (s *ClientService) OnInit() {
@ -108,3 +108,8 @@ func (s *ClientService) SendMsg(serviceTypeId pb.ServiceTypeId, msgId int32, msg
data, _ := proto.Marshal(msg) data, _ := proto.Marshal(msg)
s.SendData(serviceTypeId, msgId, data) s.SendData(serviceTypeId, msgId, data)
} }
func (s *ClientService) Log(format string, a ...any) string {
head := fmt.Sprintf("user:%v ", s.userId)
return head + fmt.Sprintf(format, a...)
}