From ff058d4a092251e7f66ecdb2e8e348d010f7ec3d Mon Sep 17 00:00:00 2001 From: liuxiaobo <1224730913@qq.com> Date: Sun, 8 Jun 2025 22:51:10 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E5=86=99=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/chat/server/processor.go | 8 ++++---- server/client/server/chat.go | 2 +- server/client/server/login.go | 4 ++-- server/client/server/processor.go | 2 +- server/colorgame/room/c2s.go | 4 ++-- server/colorgame/server/processor.go | 6 +++--- server/gate/server/processor.go | 16 ++++++++-------- server/gate/server/service.go | 6 +++--- server/login/server/processor.go | 10 +++++----- server/match/server/match.go | 14 +++++++------- 10 files changed, 36 insertions(+), 36 deletions(-) diff --git a/server/chat/server/processor.go b/server/chat/server/processor.go index ba59b48..775b862 100644 --- a/server/chat/server/processor.go +++ b/server/chat/server/processor.go @@ -10,21 +10,21 @@ import ( func (s *ChatService) initProcessor() { s.processor.RegisterMessages(processor.RegisterMetas{ - pb.MsgId_C2SChatId: {pb.C2SChat{}, s.onChat}, + pb.MsgId_ReqChatId: {pb.ReqChat{}, s.onChat}, }) } // 收到登陆成功消息,判断是否顶号 -func (s *ChatService) onChat(uid int64, msg *pb.C2SChat) { +func (s *ChatService) onChat(uid int64, msg *pb.ReqChat) { switch msg.Type { case pb.ChatType_CT_Private: tName, _ := s.bindService.FindTopic(msg.DstUser.UserId, pb.ServiceTypeId_STI_Gate) if tName == "" { log.DebugF("user:%v find gate failed", uid) } - s.SendServiceMsg(service.TopicEx(tName), msg.DstUser.UserId, int32(pb.MsgId_S2CChatId), msg) + s.SendServiceMsg(service.TopicEx(tName), msg.DstUser.UserId, int32(pb.MsgId_RspChatId), msg) default: - s.SendServiceMsg(service.TopicEx(topicName.WorldMessage), uid, int32(pb.MsgId_S2CChatId), msg) + s.SendServiceMsg(service.TopicEx(topicName.WorldMessage), uid, int32(pb.MsgId_RspChatId), msg) } } diff --git a/server/client/server/chat.go b/server/client/server/chat.go index c84f75e..ebce578 100644 --- a/server/client/server/chat.go +++ b/server/client/server/chat.go @@ -17,7 +17,7 @@ func (s *ClientService) chat() { } // 收到登陆成功消息,判断是否顶号 -func (s *ClientService) onChat(cMsg *pb.ClientMsg, msg *pb.S2CUserLogin) { +func (s *ClientService) onChat(cMsg *pb.ClientMsg, msg *pb.RspUserLogin) { if msg.Code != pb.ErrCode_OK { log.ErrorF("login error: %v", msg.Code) return diff --git a/server/client/server/login.go b/server/client/server/login.go index a3ad993..8509b66 100644 --- a/server/client/server/login.go +++ b/server/client/server/login.go @@ -7,7 +7,7 @@ import ( func (s *ClientService) login() { log.DebugF("user:%v ready login", s.username) - s.SendMsg(pb.ServiceTypeId_STI_Login, int32(pb.MsgId_C2SUserLoginId), &pb.C2SUserLogin{ + s.SendMsg(pb.ServiceTypeId_STI_Login, int32(pb.MsgId_ReqUserLoginId), &pb.ReqUserLogin{ Username: s.username, Password: s.password, Ip: "", @@ -17,7 +17,7 @@ func (s *ClientService) login() { } // 收到登陆成功消息,判断是否顶号 -func (s *ClientService) onLogin(cMsg *pb.ClientMsg, msg *pb.S2CUserLogin) { +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()) return diff --git a/server/client/server/processor.go b/server/client/server/processor.go index c2422db..322f61e 100644 --- a/server/client/server/processor.go +++ b/server/client/server/processor.go @@ -7,6 +7,6 @@ import ( func (s *ClientService) initProcessor() { s.processor.RegisterMessages(processor.RegisterMetas{ - pb.MsgId_S2CUserLoginId: {pb.S2CUserLogin{}, s.onLogin}, + pb.MsgId_RspUserLoginId: {pb.RspUserLogin{}, s.onLogin}, }) } diff --git a/server/colorgame/room/c2s.go b/server/colorgame/room/c2s.go index d882601..f04a211 100644 --- a/server/colorgame/room/c2s.go +++ b/server/colorgame/room/c2s.go @@ -5,12 +5,12 @@ import ( "github.com/fox/fox/ipb" ) -func (rm *ColorRoom) checkEnterRoom(user *ColorPlayer, iMsg *ipb.InternalMsg, req *pb.C2SMatchRoom) { +func (rm *ColorRoom) checkEnterRoom(user *ColorPlayer, iMsg *ipb.InternalMsg, req *pb.ReqMatchRoom) { return } -func (rm *ColorRoom) OnEnterRoom(user *ColorPlayer, iMsg *ipb.InternalMsg, req *pb.C2SMatchRoom) { +func (rm *ColorRoom) OnEnterRoom(user *ColorPlayer, iMsg *ipb.InternalMsg, req *pb.ReqMatchRoom) { return } diff --git a/server/colorgame/server/processor.go b/server/colorgame/server/processor.go index 733f280..0d34728 100644 --- a/server/colorgame/server/processor.go +++ b/server/colorgame/server/processor.go @@ -16,17 +16,17 @@ const ( func (s *ColorService) initProcessor() { s.processor.RegisterMessages(processor.RegisterMetas{ - pb.MsgId_C2SMatchRoomId: {pb.C2SMatchRoom{}, s.onEnterRoom}, + pb.MsgId_ReqMatchRoomId: {pb.ReqMatchRoom{}, s.onEnterRoom}, }) } // 登录或注册 -func (s *ColorService) onEnterRoom(iMsg *ipb.InternalMsg, req *pb.C2SMatchRoom) { +func (s *ColorService) onEnterRoom(iMsg *ipb.InternalMsg, req *pb.ReqMatchRoom) { ksync.GoSafe(func() { us, code := rpc.RpcGetGameUser(s.bindService, s, iMsg.UserId) if code != pb.ErrCode_OK { s.SendServiceMsg(service.TopicEx(iMsg.ServiceName), iMsg.ConnId, iMsg.UserId, - int32(pb.MsgId_S2CMatchRoomId), &pb.S2CMatchRoom{Code: pb.ErrCode_SystemErr}) + int32(pb.MsgId_RspMatchRoomId), &pb.RspMatchRoom{Code: pb.ErrCode_SystemErr}) } // 切回服务协程处理业务逻辑 s.RunOnce(func() { diff --git a/server/gate/server/processor.go b/server/gate/server/processor.go index 7136d57..8eb8c87 100644 --- a/server/gate/server/processor.go +++ b/server/gate/server/processor.go @@ -14,38 +14,38 @@ import ( */ func (s *GateService) initProcessor() { s.processor.RegisterMessages(processor.RegisterMetas{ - pb.MsgId_S2CUserLoginId: {pb.S2CUserLogin{}, s.onUserLogin}, - pb.MsgId_S2CUserLogoutId: {pb.S2CUserLogout{}, s.onUserLogout}, + pb.MsgId_RspUserLoginId: {pb.RspUserLogin{}, s.onUserLogin}, + pb.MsgId_RspUserLogoutId: {pb.RspUserLogout{}, s.onUserLogout}, }) } // 收到登陆成功消息,判断是否顶号 -func (s *GateService) onUserLogin(iMsg *ipb.InternalMsg, conn ws.IConn, msg *pb.S2CUserLogin) { +func (s *GateService) onUserLogin(iMsg *ipb.InternalMsg, conn ws.IConn, msg *pb.RspUserLogin) { if conn == nil { return } // 登陆失败,回传玩家 if msg.Code != pb.ErrCode_OK { - s.SendClientMsg(conn, iMsg.ServiceName, int32(pb.MsgId_S2CUserLoginId), msg) + s.SendClientMsg(conn, iMsg.ServiceName, int32(pb.MsgId_RspUserLoginId), msg) return } - s.SendClientMsg(conn, iMsg.ServiceName, int32(pb.MsgId_S2CUserLoginId), msg) + s.SendClientMsg(conn, iMsg.ServiceName, int32(pb.MsgId_RspUserLoginId), msg) s.wss.SetUserId(conn.Id(), msg.UserId) sName := s.bindService.LoadFromRedis(conn.UserId(), pb.ServiceTypeId_STI_Gate) // 网关不同,说明玩家在其它网关上登陆, if sName != "" && sName != s.Name() { - s.SendServiceMsg(service.TopicEx(sName), conn, int32(pb.MsgId_S2CUserLogoutId), &pb.S2CUserLogout{Code: pb.ErrCode_LoginDiffLoc}) + s.SendServiceMsg(service.TopicEx(sName), conn, int32(pb.MsgId_RspUserLogoutId), &pb.RspUserLogout{Code: pb.ErrCode_LoginDiffLoc}) } // 广播玩家上线 s.SendServiceMsg(topicName.UserOnline, conn, int32(pb.MsgId_NtfUserOnlineId), &pb.NtfUserOnline{UserId: msg.UserId}) } // 收到登出消息 -func (s *GateService) onUserLogout(iMsg *ipb.InternalMsg, conn ws.IConn, msg *pb.S2CUserLogout) { +func (s *GateService) onUserLogout(iMsg *ipb.InternalMsg, conn ws.IConn, msg *pb.RspUserLogout) { if conn == nil { return } - s.SendClientMsg(conn, iMsg.ServiceName, int32(pb.MsgId_S2CUserLogoutId), msg) + s.SendClientMsg(conn, iMsg.ServiceName, int32(pb.MsgId_RspUserLogoutId), msg) // 登出的清理工作由WsOnDisconnect实现 conn.Close() } diff --git a/server/gate/server/service.go b/server/gate/server/service.go index 9eee3a5..4db685c 100644 --- a/server/gate/server/service.go +++ b/server/gate/server/service.go @@ -115,7 +115,7 @@ func (s *GateService) OnStop() { func (s *GateService) findConn(msg *ipb.InternalMsg) ws.IConn { switch msg.MsgId { - case int32(pb.MsgId_S2CUserLoginId): + case int32(pb.MsgId_RspUserLoginId): conn, _ := s.wss.FindConnByConnId(msg.ConnId) return conn default: @@ -169,8 +169,8 @@ func (s *GateService) WsOnMessage(conn ws.IConn, data []byte) { topic, msg.ServiceName = s.bindService.FindTopic(conn.UserId(), msg.ServiceTid) } if topic != "" { - if msg.MsgId == int32(pb.MsgId_C2SUserLoginId) { - req := &pb.C2SUserLogin{} + if msg.MsgId == int32(pb.MsgId_ReqUserLoginId) { + req := &pb.ReqUserLogin{} _ = proto.Unmarshal(msg.Data, req) req.Ip = conn.Addr() msg.Data, _ = proto.Marshal(req) diff --git a/server/login/server/processor.go b/server/login/server/processor.go index 4f542b7..a3a25e1 100644 --- a/server/login/server/processor.go +++ b/server/login/server/processor.go @@ -21,11 +21,11 @@ const ( func (s *LoginService) initProcessor() { s.processor.RegisterMessages(processor.RegisterMetas{ - pb.MsgId_C2SUserLoginId: {pb.C2SUserLogin{}, s.onLoginOrRegister}, + pb.MsgId_ReqUserLoginId: {pb.ReqUserLogin{}, s.onLoginOrRegister}, }) } -func (s *LoginService) checkLoginOrRegister(req *pb.C2SUserLogin) (us *user.UserAccount, code pb.ErrCode, node *etcd.ServiceNode) { +func (s *LoginService) checkLoginOrRegister(req *pb.ReqUserLogin) (us *user.UserAccount, code pb.ErrCode, node *etcd.ServiceNode) { var err error node, err = s.bindService.RandServiceNode(pb.ServiceTypeId_STI_DB) if err != nil { @@ -116,11 +116,11 @@ func (s *LoginService) getUser(accountId int64, tName string) (*user.User, pb.Er } // 登录或注册 -func (s *LoginService) onLoginOrRegister(iMsg *ipb.InternalMsg, req *pb.C2SUserLogin) { +func (s *LoginService) onLoginOrRegister(iMsg *ipb.InternalMsg, req *pb.ReqUserLogin) { ksync.GoSafe(func() { account, code, node := s.checkLoginOrRegister(req) userId := int64(0) - rsp := &pb.S2CUserLogin{Code: code} + rsp := &pb.RspUserLogin{Code: code} if account != nil && code == pb.ErrCode_OK { // 拉取用户数据 us := &user.User{} @@ -131,7 +131,7 @@ func (s *LoginService) onLoginOrRegister(iMsg *ipb.InternalMsg, req *pb.C2SUserL userId = rsp.UserId } } - s.SendServiceMsg(service.TopicEx(iMsg.ServiceName), iMsg.ConnId, userId, int32(pb.MsgId_S2CUserLoginId), rsp) + s.SendServiceMsg(service.TopicEx(iMsg.ServiceName), iMsg.ConnId, userId, int32(pb.MsgId_RspUserLoginId), rsp) if account != nil && account.ID > 0 { loginLog := &user.UserLoginLog{ diff --git a/server/match/server/match.go b/server/match/server/match.go index 708abf2..941d040 100644 --- a/server/match/server/match.go +++ b/server/match/server/match.go @@ -12,7 +12,7 @@ import ( ) // 匹配房间 -func (s *MatchService) onMatchRoom(iMsg *ipb.InternalMsg, req *pb.C2SMatchRoom) { +func (s *MatchService) onMatchRoom(iMsg *ipb.InternalMsg, req *pb.ReqMatchRoom) { ksync.GoSafe(func() { // color game无需进入匹配队列 playType := pb.ServiceTypeId(req.PlayType) @@ -22,18 +22,18 @@ func (s *MatchService) onMatchRoom(iMsg *ipb.InternalMsg, req *pb.C2SMatchRoom) if err != nil { log.ErrorF("db service node error:%v", err) s.SendServiceMsg(service.TopicEx(iMsg.ServiceName), iMsg.ConnId, iMsg.UserId, - int32(pb.MsgId_S2CMatchRoomId), &pb.S2CMatchRoom{Code: pb.ErrCode_SystemErr}) + int32(pb.MsgId_RspMatchRoomId), &pb.RspMatchRoom{Code: pb.ErrCode_SystemErr}) return } - s.SendServiceMsg(service.TopicEx(node.Name), iMsg.ConnId, iMsg.UserId, int32(pb.MsgId_C2SMatchRoomId), req) + s.SendServiceMsg(service.TopicEx(node.Name), iMsg.ConnId, iMsg.UserId, int32(pb.MsgId_ReqMatchRoomId), req) return } var us *user.GameUser - rsp := &pb.S2CMatchRoom{} + rsp := &pb.RspMatchRoom{} us, rsp.Code = rpc.RpcGetGameUser(s.bindService, s, iMsg.UserId) if rsp.Code != pb.ErrCode_OK { - s.SendServiceMsg(service.TopicEx(iMsg.ServiceName), iMsg.ConnId, iMsg.UserId, int32(pb.MsgId_S2CMatchRoomId), rsp) + s.SendServiceMsg(service.TopicEx(iMsg.ServiceName), iMsg.ConnId, iMsg.UserId, int32(pb.MsgId_RspMatchRoomId), rsp) return } vipLv, vipExp := utils.VipLevel(us.VipExp) @@ -51,9 +51,9 @@ func (s *MatchService) onMatchRoom(iMsg *ipb.InternalMsg, req *pb.C2SMatchRoom) rsp.RoomType = req.RoomType switch pb.ServiceTypeId(rsp.PlayType) { case pb.ServiceTypeId_STI_ColorGame: - rsp.ColorInfo = &pb.S2CMatchRoom_ColorInfo{} + rsp.ColorInfo = &pb.RspMatchRoom_ColorInfo{} } - s.SendServiceMsg(service.TopicEx(iMsg.ServiceName), iMsg.ConnId, iMsg.UserId, int32(pb.MsgId_S2CMatchRoomId), rsp) + s.SendServiceMsg(service.TopicEx(iMsg.ServiceName), iMsg.ConnId, iMsg.UserId, int32(pb.MsgId_RspMatchRoomId), rsp) }, nil) }