This commit is contained in:
aozhiwei 2024-04-16 19:40:37 +08:00
parent e80f32c70b
commit 612c46eea8
6 changed files with 49 additions and 0 deletions

View File

@ -50,6 +50,7 @@ type Player interface {
GetSessionId() string
SendMsg(proto.Message)
IsOnline() bool
IsBattling() bool
}
type PlayerMgr interface {

View File

@ -51,6 +51,7 @@ type MsgHandler interface {
CMRemoveBlacklist(*f5.MsgHdr, *CMRemoveBlacklist)
CMInviteFriendMsg(*f5.MsgHdr, *CMInviteFriendMsg)
CMRecommendList(*f5.MsgHdr, *CMRecommendList)
CMSetStatus(*f5.MsgHdr, *CMSetStatus)
CMSendChatMsg(*f5.MsgHdr, *CMSendChatMsg)
CMReadMsgAndOpenChatNotify(*f5.MsgHdr, *CMReadMsgAndOpenChatNotify)
CMSetCurrPrivateChatTarget(*f5.MsgHdr, *CMSetCurrPrivateChatTarget)
@ -124,6 +125,9 @@ func (this *MsgHandlerImpl) CMInviteFriendMsg(hdr *f5.MsgHdr, msg *CMInviteFrien
func (this *MsgHandlerImpl) CMRecommendList(hdr *f5.MsgHdr, msg *CMRecommendList) {
}
func (this *MsgHandlerImpl) CMSetStatus(hdr *f5.MsgHdr, msg *CMSetStatus) {
}
func (this *MsgHandlerImpl) CMSendChatMsg(hdr *f5.MsgHdr, msg *CMSendChatMsg) {
}
@ -325,6 +329,14 @@ func (this *SMRecommendList) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMRecommendList)
}
func (this *CMSetStatus) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMSetStatus)
}
func (this *SMSetStatus) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMSetStatus)
}
func (this *CMSendChatMsg) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMSendChatMsg)
}
@ -931,6 +943,18 @@ func init() {
},
}
handlers[int(CMMessageIdE__CMSetStatus)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMSetStatus),
ParseCb: func (data []byte) interface{} {
msg := &CMSetStatus{}
proto.Unmarshal(data, msg)
return msg
},
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMSetStatus(hdr, hdr.Msg.(*CMSetStatus))
},
}
handlers[int(CMMessageIdE__CMSendChatMsg)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMSendChatMsg),
ParseCb: func (data []byte) interface{} {

View File

@ -30,6 +30,7 @@ func (this *HandlerMgr) Init() {
cs.RegHandlerId(int(cs.CMMessageIdE__CMRemoveBlacklist), constant.PLAYER_HANDLER_ID)
cs.RegHandlerId(int(cs.CMMessageIdE__CMInviteFriendMsg), constant.PLAYER_HANDLER_ID)
cs.RegHandlerId(int(cs.CMMessageIdE__CMRecommendList), constant.PLAYER_HANDLER_ID)
cs.RegHandlerId(int(cs.CMMessageIdE__CMSetStatus), constant.PLAYER_HANDLER_ID)
cs.RegHandlerId(int(cs.CMMessageIdE__CMGuildInfo), constant.PLAYER_HANDLER_ID)
cs.RegHandlerId(int(cs.CMMessageIdE__CMRecommendGuildList), constant.PLAYER_HANDLER_ID)

View File

@ -15,6 +15,7 @@ type player struct {
socket f5.WspCliConn
accountId string
sessionId string
battling bool
}
func (this *player) init(req *pendingLoginRequest, rspObj *common.LoginRsp){
@ -35,6 +36,10 @@ func (this *player) IsOnline() bool {
return this.socket.IsValid()
}
func (this *player) IsBattling() bool {
return this.battling
}
func (this *player) SendMsg(rspMsg proto.Message) {
GetWspListener().SendProxyMsg(this.socket.Conn, this.socket.SocketHandle, rspMsg)
}
@ -339,6 +344,12 @@ func (this *player) CMRecommendList(hdr *f5.MsgHdr, msg *cs.CMRecommendList) {
})
}
func (this *player) CMSetStatus(hdr *f5.MsgHdr, msg *cs.CMSetStatus) {
rspMsg := new(cs.SMSetStatus)
this.battling = msg.GetBattling() > 0
this.SendMsg(rspMsg)
}
func (this *player) CMSendChatMsg(hdr *f5.MsgHdr, msg *cs.CMSendChatMsg) {
}

View File

@ -25,6 +25,7 @@ enum CMMessageId_e
_CMBlacklist = 116;
_CMInviteFriendMsg = 117;
_CMRecommendList = 118;
_CMSetStatus = 119;
//
_CMSetCurrPrivateChatTarget = 200;
@ -75,6 +76,7 @@ enum SMMessageId_e
_SMBlacklist = 116;
_SMInviteFriendMsg = 117;
_SMRecommendList = 118;
_SMSetStatus = 119;
//
_SMGuildInfo = 120;

View File

@ -373,6 +373,16 @@ message SMRecommendList
optional int32 type = 4;
}
//
message CMSetStatus
{
optional int32 battling = 1; //
}
message SMSetStatus
{
}
// --- ---
//
message CMSendChatMsg