修改bug
This commit is contained in:
parent
3a6201381e
commit
5265c0a1e2
@ -4,11 +4,12 @@ option go_package = "common/proto/pb";
|
||||
|
||||
import "code.proto";
|
||||
import "user.proto";
|
||||
import "service.proto";
|
||||
|
||||
// 房间匹配
|
||||
message ReqMatchRoom
|
||||
{
|
||||
int32 gameId = 1; // 玩法id
|
||||
ServiceTypeId gameId = 1; // 玩法id
|
||||
int32 roomType = 2; // 房间类型,低级,中级,高级等
|
||||
}
|
||||
|
||||
@ -22,7 +23,7 @@ message RspMatchRoom
|
||||
}
|
||||
|
||||
ErrCode code = 1;
|
||||
int32 gameId = 2; // 玩法id
|
||||
ServiceTypeId gameId = 2; // 玩法id
|
||||
int32 roomType = 3; // 房间类型,低级,中级,高级等
|
||||
GameUser User = 4; // 玩家数据
|
||||
|
||||
|
@ -24,7 +24,7 @@ const (
|
||||
// 房间匹配
|
||||
type ReqMatchRoom struct {
|
||||
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"` // 房间类型,低级,中级,高级等
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
@ -60,11 +60,11 @@ func (*ReqMatchRoom) Descriptor() ([]byte, []int) {
|
||||
return file_match_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *ReqMatchRoom) GetGameId() int32 {
|
||||
func (x *ReqMatchRoom) GetGameId() ServiceTypeId {
|
||||
if x != nil {
|
||||
return x.GameId
|
||||
}
|
||||
return 0
|
||||
return ServiceTypeId_STI_Unknown
|
||||
}
|
||||
|
||||
func (x *ReqMatchRoom) GetRoomType() int32 {
|
||||
@ -78,7 +78,7 @@ func (x *ReqMatchRoom) GetRoomType() int32 {
|
||||
type RspMatchRoom struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
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"` // 房间类型,低级,中级,高级等
|
||||
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玩法配置信息
|
||||
@ -123,11 +123,11 @@ func (x *RspMatchRoom) GetCode() ErrCode {
|
||||
return ErrCode_OK
|
||||
}
|
||||
|
||||
func (x *RspMatchRoom) GetGameId() int32 {
|
||||
func (x *RspMatchRoom) GetGameId() ServiceTypeId {
|
||||
if x != nil {
|
||||
return x.GameId
|
||||
}
|
||||
return 0
|
||||
return ServiceTypeId_STI_Unknown
|
||||
}
|
||||
|
||||
func (x *RspMatchRoom) GetRoomType() int32 {
|
||||
@ -238,13 +238,13 @@ const file_match_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\vmatch.proto\x12\x02pb\x1a\n" +
|
||||
"code.proto\x1a\n" +
|
||||
"user.proto\"B\n" +
|
||||
"\fReqMatchRoom\x12\x16\n" +
|
||||
"\x06gameId\x18\x01 \x01(\x05R\x06gameId\x12\x1a\n" +
|
||||
"\broomType\x18\x02 \x01(\x05R\broomType\"\xcc\x01\n" +
|
||||
"user.proto\x1a\rservice.proto\"U\n" +
|
||||
"\fReqMatchRoom\x12)\n" +
|
||||
"\x06gameId\x18\x01 \x01(\x0e2\x11.pb.ServiceTypeIdR\x06gameId\x12\x1a\n" +
|
||||
"\broomType\x18\x02 \x01(\x05R\broomType\"\xdf\x01\n" +
|
||||
"\fRspMatchRoom\x12\x1f\n" +
|
||||
"\x04code\x18\x01 \x01(\x0e2\v.pb.ErrCodeR\x04code\x12\x16\n" +
|
||||
"\x06gameId\x18\x02 \x01(\x05R\x06gameId\x12\x1a\n" +
|
||||
"\x04code\x18\x01 \x01(\x0e2\v.pb.ErrCodeR\x04code\x12)\n" +
|
||||
"\x06gameId\x18\x02 \x01(\x0e2\x11.pb.ServiceTypeIdR\x06gameId\x12\x1a\n" +
|
||||
"\broomType\x18\x03 \x01(\x05R\broomType\x12 \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" +
|
||||
@ -270,19 +270,22 @@ var file_match_proto_goTypes = []any{
|
||||
(*RspMatchRoom)(nil), // 1: pb.RspMatchRoom
|
||||
(*NotifyUserEnterRoom)(nil), // 2: pb.NotifyUserEnterRoom
|
||||
(*RspMatchRoom_ColorInfo)(nil), // 3: pb.RspMatchRoom.ColorInfo
|
||||
(ErrCode)(0), // 4: pb.ErrCode
|
||||
(*GameUser)(nil), // 5: pb.GameUser
|
||||
(ServiceTypeId)(0), // 4: pb.ServiceTypeId
|
||||
(ErrCode)(0), // 5: pb.ErrCode
|
||||
(*GameUser)(nil), // 6: pb.GameUser
|
||||
}
|
||||
var file_match_proto_depIdxs = []int32{
|
||||
4, // 0: pb.RspMatchRoom.code:type_name -> pb.ErrCode
|
||||
5, // 1: pb.RspMatchRoom.User:type_name -> pb.GameUser
|
||||
3, // 2: pb.RspMatchRoom.colorInfo:type_name -> pb.RspMatchRoom.ColorInfo
|
||||
5, // 3: pb.NotifyUserEnterRoom.User:type_name -> pb.GameUser
|
||||
4, // [4:4] is the sub-list for method output_type
|
||||
4, // [4:4] is the sub-list for method input_type
|
||||
4, // [4:4] is the sub-list for extension type_name
|
||||
4, // [4:4] is the sub-list for extension extendee
|
||||
0, // [0:4] is the sub-list for field type_name
|
||||
4, // 0: pb.ReqMatchRoom.gameId:type_name -> pb.ServiceTypeId
|
||||
5, // 1: pb.RspMatchRoom.code:type_name -> pb.ErrCode
|
||||
4, // 2: pb.RspMatchRoom.gameId:type_name -> pb.ServiceTypeId
|
||||
6, // 3: pb.RspMatchRoom.User:type_name -> pb.GameUser
|
||||
3, // 4: pb.RspMatchRoom.colorInfo:type_name -> pb.RspMatchRoom.ColorInfo
|
||||
6, // 5: pb.NotifyUserEnterRoom.User:type_name -> pb.GameUser
|
||||
6, // [6:6] is the sub-list for method output_type
|
||||
6, // [6:6] is the sub-list for method input_type
|
||||
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() }
|
||||
@ -292,6 +295,7 @@ func file_match_proto_init() {
|
||||
}
|
||||
file_code_proto_init()
|
||||
file_user_proto_init()
|
||||
file_service_proto_init()
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
|
@ -19,10 +19,10 @@ func (s *ClientService) chat() {
|
||||
// 收到登陆成功消息,判断是否顶号
|
||||
func (s *ClientService) onChat(cMsg *pb.ClientMsg, msg *pb.RspUserLogin) {
|
||||
if msg.Code != pb.ErrCode_OK {
|
||||
log.ErrorF("login error: %v", msg.Code)
|
||||
log.ErrorF("reqLogin error: %v", msg.Code)
|
||||
return
|
||||
}
|
||||
_ = cMsg
|
||||
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)
|
||||
}
|
||||
|
24
server/client/server/colorgame.go
Normal file
24
server/client/server/colorgame.go
Normal 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)
|
||||
//}
|
@ -5,8 +5,8 @@ import (
|
||||
"github.com/fox/fox/log"
|
||||
)
|
||||
|
||||
func (s *ClientService) login() {
|
||||
log.DebugF("user:%v ready login", s.username)
|
||||
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,
|
||||
@ -19,11 +19,19 @@ func (s *ClientService) login() {
|
||||
// 收到登陆成功消息,判断是否顶号
|
||||
func (s *ClientService) onLogin(cMsg *pb.ClientMsg, msg *pb.RspUserLogin) {
|
||||
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
|
||||
}
|
||||
_ = cMsg
|
||||
s.userId = 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,
|
||||
})
|
||||
}
|
||||
|
@ -60,8 +60,8 @@ func newClientService(serviceId int) *ClientService {
|
||||
}
|
||||
|
||||
func (s *ClientService) loopLoginHour() {
|
||||
s.login()
|
||||
time.AfterFunc(5*time.Minute, s.loopLoginHour)
|
||||
s.reqLogin()
|
||||
//time.AfterFunc(5*time.Minute, s.loopLoginHour)
|
||||
}
|
||||
|
||||
func (s *ClientService) OnInit() {
|
||||
@ -108,3 +108,8 @@ func (s *ClientService) SendMsg(serviceTypeId pb.ServiceTypeId, msgId int32, msg
|
||||
data, _ := proto.Marshal(msg)
|
||||
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...)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user