This commit is contained in:
殷勇 2023-08-30 19:21:21 +08:00
parent 13feb0b8f9
commit 710b28fbc0
9 changed files with 865 additions and 296 deletions

View File

@ -49,11 +49,14 @@ type MsgHandler interface {
CMDeleteFriendShip(*f5.MsgHdr, *CMDeleteFriendShip)
CMAddBlacklist(*f5.MsgHdr, *CMAddBlacklist)
CMRemoveBlacklist(*f5.MsgHdr, *CMRemoveBlacklist)
CMSetCurrPrivateChatTarget(*f5.MsgHdr, *CMSetCurrPrivateChatTarget)
CMSendChatMsg(*f5.MsgHdr, *CMSendChatMsg)
CMReadMsgAndOpenChatNotify(*f5.MsgHdr, *CMReadMsgAndOpenChatNotify)
CMSetCurrPrivateChatTarget(*f5.MsgHdr, *CMSetCurrPrivateChatTarget)
CMCloseChatNotify(*f5.MsgHdr, *CMCloseChatNotify)
CMGuildInfo(*f5.MsgHdr, *CMGuildInfo)
CMCreateGuild(*f5.MsgHdr, *CMCreateGuild)
CMApplyToGuild(*f5.MsgHdr, *CMApplyToGuild)
CMApplyList(*f5.MsgHdr, *CMApplyList)
CMApprove(*f5.MsgHdr, *CMApprove)
CMReject(*f5.MsgHdr, *CMReject)
CMLeaveGuild(*f5.MsgHdr, *CMLeaveGuild)
@ -62,6 +65,7 @@ type MsgHandler interface {
CMDemoteMember(*f5.MsgHdr, *CMDemoteMember)
CMDisband(*f5.MsgHdr, *CMDisband)
CMSearchGuilds(*f5.MsgHdr, *CMSearchGuilds)
CMGuildLogs(*f5.MsgHdr, *CMGuildLogs)
}
func (this *MsgHandlerImpl) CMPing(hdr *f5.MsgHdr, msg *CMPing) {
@ -106,10 +110,16 @@ func (this *MsgHandlerImpl) CMAddBlacklist(hdr *f5.MsgHdr, msg *CMAddBlacklist)
func (this *MsgHandlerImpl) CMRemoveBlacklist(hdr *f5.MsgHdr, msg *CMRemoveBlacklist) {
}
func (this *MsgHandlerImpl) CMSendChatMsg(hdr *f5.MsgHdr, msg *CMSendChatMsg) {
}
func (this *MsgHandlerImpl) CMReadMsgAndOpenChatNotify(hdr *f5.MsgHdr, msg *CMReadMsgAndOpenChatNotify) {
}
func (this *MsgHandlerImpl) CMSetCurrPrivateChatTarget(hdr *f5.MsgHdr, msg *CMSetCurrPrivateChatTarget) {
}
func (this *MsgHandlerImpl) CMSendChatMsg(hdr *f5.MsgHdr, msg *CMSendChatMsg) {
func (this *MsgHandlerImpl) CMCloseChatNotify(hdr *f5.MsgHdr, msg *CMCloseChatNotify) {
}
func (this *MsgHandlerImpl) CMGuildInfo(hdr *f5.MsgHdr, msg *CMGuildInfo) {
@ -121,6 +131,9 @@ func (this *MsgHandlerImpl) CMCreateGuild(hdr *f5.MsgHdr, msg *CMCreateGuild) {
func (this *MsgHandlerImpl) CMApplyToGuild(hdr *f5.MsgHdr, msg *CMApplyToGuild) {
}
func (this *MsgHandlerImpl) CMApplyList(hdr *f5.MsgHdr, msg *CMApplyList) {
}
func (this *MsgHandlerImpl) CMApprove(hdr *f5.MsgHdr, msg *CMApprove) {
}
@ -145,6 +158,9 @@ func (this *MsgHandlerImpl) CMDisband(hdr *f5.MsgHdr, msg *CMDisband) {
func (this *MsgHandlerImpl) CMSearchGuilds(hdr *f5.MsgHdr, msg *CMSearchGuilds) {
}
func (this *MsgHandlerImpl) CMGuildLogs(hdr *f5.MsgHdr, msg *CMGuildLogs) {
}
func (this *CMPing) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMPing)
}
@ -261,12 +277,20 @@ func (this *SMRemoveBlacklist) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMRemoveBlacklist)
}
func (this *CMSendChatMsg) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMSendChatMsg)
}
func (this *CMReadMsgAndOpenChatNotify) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMReadMsgAndOpenChatNotify)
}
func (this *CMSetCurrPrivateChatTarget) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMSetCurrPrivateChatTarget)
}
func (this *CMSendChatMsg) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMSendChatMsg)
func (this *CMCloseChatNotify) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMCloseChatNotify)
}
func (this *SMUpdateChatRedPointNotify) GetNetMsgId() uint16 {
@ -277,6 +301,18 @@ func (this *SMChatMsgNotify) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMChatMsgNotify)
}
func (this *SMUpdateRedPointNotify) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMUpdateRedPointNotify)
}
func (this *SMUpdatePrivateChatRedPointNotify) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMUpdatePrivateChatRedPointNotify)
}
func (this *SMUpdateChatChannelLastId) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMUpdateChatChannelLastId)
}
func (this *CMGuildInfo) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMGuildInfo)
}
@ -301,6 +337,14 @@ func (this *SMApplyToGuild) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMApplyToGuild)
}
func (this *CMApplyList) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMApplyList)
}
func (this *SMApplyList) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMApplyList)
}
func (this *CMApprove) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMApprove)
}
@ -365,6 +409,14 @@ func (this *SMSearchGuilds) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMSearchGuilds)
}
func (this *CMGuildLogs) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMGuildLogs)
}
func (this *SMGuildLogs) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMGuildLogs)
}
func init() {
handlers[int(CMMessageIdE__CMPing)] = &CsNetMsgHandler{
@ -535,6 +587,30 @@ func init() {
},
}
handlers[int(CMMessageIdE__CMSendChatMsg)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMSendChatMsg),
ParseCb: func (data []byte) interface{} {
msg := &CMSendChatMsg{}
proto.Unmarshal(data, msg)
return msg
},
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMSendChatMsg(hdr, hdr.Msg.(*CMSendChatMsg))
},
}
handlers[int(CMMessageIdE__CMReadMsgAndOpenChatNotify)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMReadMsgAndOpenChatNotify),
ParseCb: func (data []byte) interface{} {
msg := &CMReadMsgAndOpenChatNotify{}
proto.Unmarshal(data, msg)
return msg
},
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMReadMsgAndOpenChatNotify(hdr, hdr.Msg.(*CMReadMsgAndOpenChatNotify))
},
}
handlers[int(CMMessageIdE__CMSetCurrPrivateChatTarget)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMSetCurrPrivateChatTarget),
ParseCb: func (data []byte) interface{} {
@ -547,15 +623,15 @@ func init() {
},
}
handlers[int(CMMessageIdE__CMSendChatMsg)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMSendChatMsg),
handlers[int(CMMessageIdE__CMCloseChatNotify)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMCloseChatNotify),
ParseCb: func (data []byte) interface{} {
msg := &CMSendChatMsg{}
msg := &CMCloseChatNotify{}
proto.Unmarshal(data, msg)
return msg
},
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMSendChatMsg(hdr, hdr.Msg.(*CMSendChatMsg))
handler.CMCloseChatNotify(hdr, hdr.Msg.(*CMCloseChatNotify))
},
}
@ -595,6 +671,18 @@ func init() {
},
}
handlers[int(CMMessageIdE__CMApplyList)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMApplyList),
ParseCb: func (data []byte) interface{} {
msg := &CMApplyList{}
proto.Unmarshal(data, msg)
return msg
},
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMApplyList(hdr, hdr.Msg.(*CMApplyList))
},
}
handlers[int(CMMessageIdE__CMApprove)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMApprove),
ParseCb: func (data []byte) interface{} {
@ -691,4 +779,16 @@ func init() {
},
}
handlers[int(CMMessageIdE__CMGuildLogs)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMGuildLogs),
ParseCb: func (data []byte) interface{} {
msg := &CMGuildLogs{}
proto.Unmarshal(data, msg)
return msg
},
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMGuildLogs(hdr, hdr.Msg.(*CMGuildLogs))
},
}
}

View File

@ -42,6 +42,8 @@ const (
// 聊天相关
CMMessageIdE__CMSetCurrPrivateChatTarget CMMessageIdE = 200
CMMessageIdE__CMSendChatMsg CMMessageIdE = 201
CMMessageIdE__CMReadMsgAndOpenChatNotify CMMessageIdE = 202
CMMessageIdE__CMCloseChatNotify CMMessageIdE = 203
// 公会相关
CMMessageIdE__CMGuildInfo CMMessageIdE = 120
CMMessageIdE__CMCreateGuild CMMessageIdE = 121
@ -54,6 +56,8 @@ const (
CMMessageIdE__CMDemoteMember CMMessageIdE = 128
CMMessageIdE__CMDisband CMMessageIdE = 129
CMMessageIdE__CMSearchGuilds CMMessageIdE = 130
CMMessageIdE__CMApplyList CMMessageIdE = 131
CMMessageIdE__CMGuildLogs CMMessageIdE = 132
)
// Enum value maps for CMMessageIdE.
@ -75,6 +79,8 @@ var (
115: "_CMFriendInfo",
200: "_CMSetCurrPrivateChatTarget",
201: "_CMSendChatMsg",
202: "_CMReadMsgAndOpenChatNotify",
203: "_CMCloseChatNotify",
120: "_CMGuildInfo",
121: "_CMCreateGuild",
122: "_CMApplyToGuild",
@ -86,6 +92,8 @@ var (
128: "_CMDemoteMember",
129: "_CMDisband",
130: "_CMSearchGuilds",
131: "_CMApplyList",
132: "_CMGuildLogs",
}
CMMessageIdE_value = map[string]int32{
"_CMPing": 101,
@ -104,6 +112,8 @@ var (
"_CMFriendInfo": 115,
"_CMSetCurrPrivateChatTarget": 200,
"_CMSendChatMsg": 201,
"_CMReadMsgAndOpenChatNotify": 202,
"_CMCloseChatNotify": 203,
"_CMGuildInfo": 120,
"_CMCreateGuild": 121,
"_CMApplyToGuild": 122,
@ -115,6 +125,8 @@ var (
"_CMDemoteMember": 128,
"_CMDisband": 129,
"_CMSearchGuilds": 130,
"_CMApplyList": 131,
"_CMGuildLogs": 132,
}
)
@ -185,9 +197,14 @@ const (
SMMessageIdE__SMDemoteMember SMMessageIdE = 128
SMMessageIdE__SMDisband SMMessageIdE = 129
SMMessageIdE__SMSearchGuilds SMMessageIdE = 130
SMMessageIdE__SMApplyList SMMessageIdE = 131
SMMessageIdE__SMGuildLogs SMMessageIdE = 132
// 聊天相关
SMMessageIdE__SMUpdateChatRedPointNotify SMMessageIdE = 200
SMMessageIdE__SMChatMsgNotify SMMessageIdE = 201
SMMessageIdE__SMUpdateChatRedPointNotify SMMessageIdE = 200
SMMessageIdE__SMChatMsgNotify SMMessageIdE = 201
SMMessageIdE__SMUpdateRedPointNotify SMMessageIdE = 202
SMMessageIdE__SMUpdatePrivateChatRedPointNotify SMMessageIdE = 203
SMMessageIdE__SMUpdateChatChannelLastId SMMessageIdE = 204
)
// Enum value maps for SMMessageIdE.
@ -219,38 +236,48 @@ var (
128: "_SMDemoteMember",
129: "_SMDisband",
130: "_SMSearchGuilds",
131: "_SMApplyList",
132: "_SMGuildLogs",
200: "_SMUpdateChatRedPointNotify",
201: "_SMChatMsgNotify",
202: "_SMUpdateRedPointNotify",
203: "_SMUpdatePrivateChatRedPointNotify",
204: "_SMUpdateChatChannelLastId",
}
SMMessageIdE_value = map[string]int32{
"_SMPing": 101,
"_SMRpcError": 102,
"_SMLogin": 103,
"_SMReconnect": 104,
"_SMSearchUserByAccountId": 105,
"_SMSearchUser": 106,
"_SMAddFriendRequest": 107,
"_SMAcceptFriendRequest": 108,
"_SMRejectFriendRequest": 109,
"_SMListPendingFriendRequest": 110,
"_SMListFriend": 111,
"_SMDeleteFriendShip": 112,
"_SMAddBlacklist": 113,
"_SMRemoveBlacklist": 114,
"_SMFriendInfo": 115,
"_SMGuildInfo": 120,
"_SMCreateGuild": 121,
"_SMApplyToGuild": 122,
"_SMApprove": 123,
"_SMReject": 124,
"_SMLeaveGuild": 125,
"_SMDismissMember": 126,
"_SMPromoteMember": 127,
"_SMDemoteMember": 128,
"_SMDisband": 129,
"_SMSearchGuilds": 130,
"_SMUpdateChatRedPointNotify": 200,
"_SMChatMsgNotify": 201,
"_SMPing": 101,
"_SMRpcError": 102,
"_SMLogin": 103,
"_SMReconnect": 104,
"_SMSearchUserByAccountId": 105,
"_SMSearchUser": 106,
"_SMAddFriendRequest": 107,
"_SMAcceptFriendRequest": 108,
"_SMRejectFriendRequest": 109,
"_SMListPendingFriendRequest": 110,
"_SMListFriend": 111,
"_SMDeleteFriendShip": 112,
"_SMAddBlacklist": 113,
"_SMRemoveBlacklist": 114,
"_SMFriendInfo": 115,
"_SMGuildInfo": 120,
"_SMCreateGuild": 121,
"_SMApplyToGuild": 122,
"_SMApprove": 123,
"_SMReject": 124,
"_SMLeaveGuild": 125,
"_SMDismissMember": 126,
"_SMPromoteMember": 127,
"_SMDemoteMember": 128,
"_SMDisband": 129,
"_SMSearchGuilds": 130,
"_SMApplyList": 131,
"_SMGuildLogs": 132,
"_SMUpdateChatRedPointNotify": 200,
"_SMChatMsgNotify": 201,
"_SMUpdateRedPointNotify": 202,
"_SMUpdatePrivateChatRedPointNotify": 203,
"_SMUpdateChatChannelLastId": 204,
}
)
@ -295,7 +322,7 @@ var File_cs_msgid_proto protoreflect.FileDescriptor
var file_cs_msgid_proto_rawDesc = []byte{
0x0a, 0x0e, 0x63, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x69, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x12, 0x02, 0x63, 0x73, 0x2a, 0xd8, 0x04, 0x0a, 0x0d, 0x43, 0x4d, 0x4d, 0x65, 0x73, 0x73, 0x61,
0x12, 0x02, 0x63, 0x73, 0x2a, 0xb9, 0x05, 0x0a, 0x0d, 0x43, 0x4d, 0x4d, 0x65, 0x73, 0x73, 0x61,
0x67, 0x65, 0x49, 0x64, 0x5f, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x5f, 0x43, 0x4d, 0x50, 0x69, 0x6e,
0x67, 0x10, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x5f, 0x43, 0x4d, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x10,
0x67, 0x12, 0x10, 0x0a, 0x0c, 0x5f, 0x43, 0x4d, 0x52, 0x65, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63,
@ -319,60 +346,75 @@ var file_cs_msgid_proto_rawDesc = []byte{
0x10, 0x73, 0x12, 0x20, 0x0a, 0x1b, 0x5f, 0x43, 0x4d, 0x53, 0x65, 0x74, 0x43, 0x75, 0x72, 0x72,
0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x74, 0x54, 0x61, 0x72, 0x67, 0x65,
0x74, 0x10, 0xc8, 0x01, 0x12, 0x13, 0x0a, 0x0e, 0x5f, 0x43, 0x4d, 0x53, 0x65, 0x6e, 0x64, 0x43,
0x68, 0x61, 0x74, 0x4d, 0x73, 0x67, 0x10, 0xc9, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x5f, 0x43, 0x4d,
0x47, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x10, 0x78, 0x12, 0x12, 0x0a, 0x0e, 0x5f,
0x43, 0x4d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x10, 0x79, 0x12,
0x13, 0x0a, 0x0f, 0x5f, 0x43, 0x4d, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x54, 0x6f, 0x47, 0x75, 0x69,
0x6c, 0x64, 0x10, 0x7a, 0x12, 0x0e, 0x0a, 0x0a, 0x5f, 0x43, 0x4d, 0x41, 0x70, 0x70, 0x72, 0x6f,
0x76, 0x65, 0x10, 0x7b, 0x12, 0x0d, 0x0a, 0x09, 0x5f, 0x43, 0x4d, 0x52, 0x65, 0x6a, 0x65, 0x63,
0x74, 0x10, 0x7c, 0x12, 0x11, 0x0a, 0x0d, 0x5f, 0x43, 0x4d, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x47,
0x75, 0x69, 0x6c, 0x64, 0x10, 0x7d, 0x12, 0x14, 0x0a, 0x10, 0x5f, 0x43, 0x4d, 0x44, 0x69, 0x73,
0x6d, 0x69, 0x73, 0x73, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x10, 0x7e, 0x12, 0x14, 0x0a, 0x10,
0x5f, 0x43, 0x4d, 0x50, 0x72, 0x6f, 0x6d, 0x6f, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72,
0x10, 0x7f, 0x12, 0x14, 0x0a, 0x0f, 0x5f, 0x43, 0x4d, 0x44, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x4d,
0x65, 0x6d, 0x62, 0x65, 0x72, 0x10, 0x80, 0x01, 0x12, 0x0f, 0x0a, 0x0a, 0x5f, 0x43, 0x4d, 0x44,
0x69, 0x73, 0x62, 0x61, 0x6e, 0x64, 0x10, 0x81, 0x01, 0x12, 0x14, 0x0a, 0x0f, 0x5f, 0x43, 0x4d,
0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x73, 0x10, 0x82, 0x01, 0x2a,
0xeb, 0x04, 0x0a, 0x0d, 0x53, 0x4d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x64, 0x5f,
0x65, 0x12, 0x0b, 0x0a, 0x07, 0x5f, 0x53, 0x4d, 0x50, 0x69, 0x6e, 0x67, 0x10, 0x65, 0x12, 0x0f,
0x0a, 0x0b, 0x5f, 0x53, 0x4d, 0x52, 0x70, 0x63, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x66, 0x12,
0x0c, 0x0a, 0x08, 0x5f, 0x53, 0x4d, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x10, 0x67, 0x12, 0x10, 0x0a,
0x0c, 0x5f, 0x53, 0x4d, 0x52, 0x65, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x10, 0x68, 0x12,
0x1c, 0x0a, 0x18, 0x5f, 0x53, 0x4d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x55, 0x73, 0x65, 0x72,
0x42, 0x79, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x10, 0x69, 0x12, 0x11, 0x0a,
0x0d, 0x5f, 0x53, 0x4d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x55, 0x73, 0x65, 0x72, 0x10, 0x6a,
0x12, 0x17, 0x0a, 0x13, 0x5f, 0x53, 0x4d, 0x41, 0x64, 0x64, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x10, 0x6b, 0x12, 0x1a, 0x0a, 0x16, 0x5f, 0x53, 0x4d,
0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x10, 0x6c, 0x12, 0x1a, 0x0a, 0x16, 0x5f, 0x53, 0x4d, 0x52, 0x65, 0x6a, 0x65,
0x63, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x10,
0x6d, 0x12, 0x1f, 0x0a, 0x1b, 0x5f, 0x53, 0x4d, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x6e, 0x64,
0x69, 0x6e, 0x67, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x10, 0x6e, 0x12, 0x11, 0x0a, 0x0d, 0x5f, 0x53, 0x4d, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x72, 0x69,
0x65, 0x6e, 0x64, 0x10, 0x6f, 0x12, 0x17, 0x0a, 0x13, 0x5f, 0x53, 0x4d, 0x44, 0x65, 0x6c, 0x65,
0x74, 0x65, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x68, 0x69, 0x70, 0x10, 0x70, 0x12, 0x13,
0x0a, 0x0f, 0x5f, 0x53, 0x4d, 0x41, 0x64, 0x64, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x6c, 0x69, 0x73,
0x74, 0x10, 0x71, 0x12, 0x16, 0x0a, 0x12, 0x5f, 0x53, 0x4d, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65,
0x42, 0x6c, 0x61, 0x63, 0x6b, 0x6c, 0x69, 0x73, 0x74, 0x10, 0x72, 0x12, 0x11, 0x0a, 0x0d, 0x5f,
0x53, 0x4d, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x10, 0x73, 0x12, 0x10,
0x0a, 0x0c, 0x5f, 0x53, 0x4d, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x10, 0x78,
0x12, 0x12, 0x0a, 0x0e, 0x5f, 0x53, 0x4d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x75, 0x69,
0x6c, 0x64, 0x10, 0x79, 0x12, 0x13, 0x0a, 0x0f, 0x5f, 0x53, 0x4d, 0x41, 0x70, 0x70, 0x6c, 0x79,
0x54, 0x6f, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x10, 0x7a, 0x12, 0x0e, 0x0a, 0x0a, 0x5f, 0x53, 0x4d,
0x41, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x10, 0x7b, 0x12, 0x0d, 0x0a, 0x09, 0x5f, 0x53, 0x4d,
0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x10, 0x7c, 0x12, 0x11, 0x0a, 0x0d, 0x5f, 0x53, 0x4d, 0x4c,
0x65, 0x61, 0x76, 0x65, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x10, 0x7d, 0x12, 0x14, 0x0a, 0x10, 0x5f,
0x53, 0x4d, 0x44, 0x69, 0x73, 0x6d, 0x69, 0x73, 0x73, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x10,
0x7e, 0x12, 0x14, 0x0a, 0x10, 0x5f, 0x53, 0x4d, 0x50, 0x72, 0x6f, 0x6d, 0x6f, 0x74, 0x65, 0x4d,
0x65, 0x6d, 0x62, 0x65, 0x72, 0x10, 0x7f, 0x12, 0x14, 0x0a, 0x0f, 0x5f, 0x53, 0x4d, 0x44, 0x65,
0x6d, 0x6f, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x10, 0x80, 0x01, 0x12, 0x0f, 0x0a,
0x0a, 0x5f, 0x53, 0x4d, 0x44, 0x69, 0x73, 0x62, 0x61, 0x6e, 0x64, 0x10, 0x81, 0x01, 0x12, 0x14,
0x0a, 0x0f, 0x5f, 0x53, 0x4d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x47, 0x75, 0x69, 0x6c, 0x64,
0x73, 0x10, 0x82, 0x01, 0x12, 0x20, 0x0a, 0x1b, 0x5f, 0x53, 0x4d, 0x55, 0x70, 0x64, 0x61, 0x74,
0x65, 0x43, 0x68, 0x61, 0x74, 0x52, 0x65, 0x64, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x4e, 0x6f, 0x74,
0x69, 0x66, 0x79, 0x10, 0xc8, 0x01, 0x12, 0x15, 0x0a, 0x10, 0x5f, 0x53, 0x4d, 0x43, 0x68, 0x61,
0x74, 0x4d, 0x73, 0x67, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x10, 0xc9, 0x01, 0x42, 0x06, 0x5a,
0x04, 0x2e, 0x3b, 0x63, 0x73,
0x68, 0x61, 0x74, 0x4d, 0x73, 0x67, 0x10, 0xc9, 0x01, 0x12, 0x20, 0x0a, 0x1b, 0x5f, 0x43, 0x4d,
0x52, 0x65, 0x61, 0x64, 0x4d, 0x73, 0x67, 0x41, 0x6e, 0x64, 0x4f, 0x70, 0x65, 0x6e, 0x43, 0x68,
0x61, 0x74, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x10, 0xca, 0x01, 0x12, 0x17, 0x0a, 0x12, 0x5f,
0x43, 0x4d, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x43, 0x68, 0x61, 0x74, 0x4e, 0x6f, 0x74, 0x69, 0x66,
0x79, 0x10, 0xcb, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x5f, 0x43, 0x4d, 0x47, 0x75, 0x69, 0x6c, 0x64,
0x49, 0x6e, 0x66, 0x6f, 0x10, 0x78, 0x12, 0x12, 0x0a, 0x0e, 0x5f, 0x43, 0x4d, 0x43, 0x72, 0x65,
0x61, 0x74, 0x65, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x10, 0x79, 0x12, 0x13, 0x0a, 0x0f, 0x5f, 0x43,
0x4d, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x54, 0x6f, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x10, 0x7a, 0x12,
0x0e, 0x0a, 0x0a, 0x5f, 0x43, 0x4d, 0x41, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x10, 0x7b, 0x12,
0x0d, 0x0a, 0x09, 0x5f, 0x43, 0x4d, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x10, 0x7c, 0x12, 0x11,
0x0a, 0x0d, 0x5f, 0x43, 0x4d, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x10,
0x7d, 0x12, 0x14, 0x0a, 0x10, 0x5f, 0x43, 0x4d, 0x44, 0x69, 0x73, 0x6d, 0x69, 0x73, 0x73, 0x4d,
0x65, 0x6d, 0x62, 0x65, 0x72, 0x10, 0x7e, 0x12, 0x14, 0x0a, 0x10, 0x5f, 0x43, 0x4d, 0x50, 0x72,
0x6f, 0x6d, 0x6f, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x10, 0x7f, 0x12, 0x14, 0x0a,
0x0f, 0x5f, 0x43, 0x4d, 0x44, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72,
0x10, 0x80, 0x01, 0x12, 0x0f, 0x0a, 0x0a, 0x5f, 0x43, 0x4d, 0x44, 0x69, 0x73, 0x62, 0x61, 0x6e,
0x64, 0x10, 0x81, 0x01, 0x12, 0x14, 0x0a, 0x0f, 0x5f, 0x43, 0x4d, 0x53, 0x65, 0x61, 0x72, 0x63,
0x68, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x73, 0x10, 0x82, 0x01, 0x12, 0x11, 0x0a, 0x0c, 0x5f, 0x43,
0x4d, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x10, 0x83, 0x01, 0x12, 0x11, 0x0a,
0x0c, 0x5f, 0x43, 0x4d, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x4c, 0x6f, 0x67, 0x73, 0x10, 0x84, 0x01,
0x2a, 0xf9, 0x05, 0x0a, 0x0d, 0x53, 0x4d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x64,
0x5f, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x5f, 0x53, 0x4d, 0x50, 0x69, 0x6e, 0x67, 0x10, 0x65, 0x12,
0x0f, 0x0a, 0x0b, 0x5f, 0x53, 0x4d, 0x52, 0x70, 0x63, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x66,
0x12, 0x0c, 0x0a, 0x08, 0x5f, 0x53, 0x4d, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x10, 0x67, 0x12, 0x10,
0x0a, 0x0c, 0x5f, 0x53, 0x4d, 0x52, 0x65, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x10, 0x68,
0x12, 0x1c, 0x0a, 0x18, 0x5f, 0x53, 0x4d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x55, 0x73, 0x65,
0x72, 0x42, 0x79, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x10, 0x69, 0x12, 0x11,
0x0a, 0x0d, 0x5f, 0x53, 0x4d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x55, 0x73, 0x65, 0x72, 0x10,
0x6a, 0x12, 0x17, 0x0a, 0x13, 0x5f, 0x53, 0x4d, 0x41, 0x64, 0x64, 0x46, 0x72, 0x69, 0x65, 0x6e,
0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x10, 0x6b, 0x12, 0x1a, 0x0a, 0x16, 0x5f, 0x53,
0x4d, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x10, 0x6c, 0x12, 0x1a, 0x0a, 0x16, 0x5f, 0x53, 0x4d, 0x52, 0x65, 0x6a,
0x65, 0x63, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x10, 0x6d, 0x12, 0x1f, 0x0a, 0x1b, 0x5f, 0x53, 0x4d, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x6e,
0x64, 0x69, 0x6e, 0x67, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x10, 0x6e, 0x12, 0x11, 0x0a, 0x0d, 0x5f, 0x53, 0x4d, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x72,
0x69, 0x65, 0x6e, 0x64, 0x10, 0x6f, 0x12, 0x17, 0x0a, 0x13, 0x5f, 0x53, 0x4d, 0x44, 0x65, 0x6c,
0x65, 0x74, 0x65, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x68, 0x69, 0x70, 0x10, 0x70, 0x12,
0x13, 0x0a, 0x0f, 0x5f, 0x53, 0x4d, 0x41, 0x64, 0x64, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x6c, 0x69,
0x73, 0x74, 0x10, 0x71, 0x12, 0x16, 0x0a, 0x12, 0x5f, 0x53, 0x4d, 0x52, 0x65, 0x6d, 0x6f, 0x76,
0x65, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x6c, 0x69, 0x73, 0x74, 0x10, 0x72, 0x12, 0x11, 0x0a, 0x0d,
0x5f, 0x53, 0x4d, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x10, 0x73, 0x12,
0x10, 0x0a, 0x0c, 0x5f, 0x53, 0x4d, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x10,
0x78, 0x12, 0x12, 0x0a, 0x0e, 0x5f, 0x53, 0x4d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x75,
0x69, 0x6c, 0x64, 0x10, 0x79, 0x12, 0x13, 0x0a, 0x0f, 0x5f, 0x53, 0x4d, 0x41, 0x70, 0x70, 0x6c,
0x79, 0x54, 0x6f, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x10, 0x7a, 0x12, 0x0e, 0x0a, 0x0a, 0x5f, 0x53,
0x4d, 0x41, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x10, 0x7b, 0x12, 0x0d, 0x0a, 0x09, 0x5f, 0x53,
0x4d, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x10, 0x7c, 0x12, 0x11, 0x0a, 0x0d, 0x5f, 0x53, 0x4d,
0x4c, 0x65, 0x61, 0x76, 0x65, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x10, 0x7d, 0x12, 0x14, 0x0a, 0x10,
0x5f, 0x53, 0x4d, 0x44, 0x69, 0x73, 0x6d, 0x69, 0x73, 0x73, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72,
0x10, 0x7e, 0x12, 0x14, 0x0a, 0x10, 0x5f, 0x53, 0x4d, 0x50, 0x72, 0x6f, 0x6d, 0x6f, 0x74, 0x65,
0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x10, 0x7f, 0x12, 0x14, 0x0a, 0x0f, 0x5f, 0x53, 0x4d, 0x44,
0x65, 0x6d, 0x6f, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x10, 0x80, 0x01, 0x12, 0x0f,
0x0a, 0x0a, 0x5f, 0x53, 0x4d, 0x44, 0x69, 0x73, 0x62, 0x61, 0x6e, 0x64, 0x10, 0x81, 0x01, 0x12,
0x14, 0x0a, 0x0f, 0x5f, 0x53, 0x4d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x47, 0x75, 0x69, 0x6c,
0x64, 0x73, 0x10, 0x82, 0x01, 0x12, 0x11, 0x0a, 0x0c, 0x5f, 0x53, 0x4d, 0x41, 0x70, 0x70, 0x6c,
0x79, 0x4c, 0x69, 0x73, 0x74, 0x10, 0x83, 0x01, 0x12, 0x11, 0x0a, 0x0c, 0x5f, 0x53, 0x4d, 0x47,
0x75, 0x69, 0x6c, 0x64, 0x4c, 0x6f, 0x67, 0x73, 0x10, 0x84, 0x01, 0x12, 0x20, 0x0a, 0x1b, 0x5f,
0x53, 0x4d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x74, 0x52, 0x65, 0x64, 0x50,
0x6f, 0x69, 0x6e, 0x74, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x10, 0xc8, 0x01, 0x12, 0x15, 0x0a,
0x10, 0x5f, 0x53, 0x4d, 0x43, 0x68, 0x61, 0x74, 0x4d, 0x73, 0x67, 0x4e, 0x6f, 0x74, 0x69, 0x66,
0x79, 0x10, 0xc9, 0x01, 0x12, 0x1c, 0x0a, 0x17, 0x5f, 0x53, 0x4d, 0x55, 0x70, 0x64, 0x61, 0x74,
0x65, 0x52, 0x65, 0x64, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x10,
0xca, 0x01, 0x12, 0x27, 0x0a, 0x22, 0x5f, 0x53, 0x4d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50,
0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x74, 0x52, 0x65, 0x64, 0x50, 0x6f, 0x69,
0x6e, 0x74, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x10, 0xcb, 0x01, 0x12, 0x1f, 0x0a, 0x1a, 0x5f,
0x53, 0x4d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x74, 0x43, 0x68, 0x61, 0x6e,
0x6e, 0x65, 0x6c, 0x4c, 0x61, 0x73, 0x74, 0x49, 0x64, 0x10, 0xcc, 0x01, 0x42, 0x06, 0x5a, 0x04,
0x2e, 0x3b, 0x63, 0x73,
}
var (

File diff suppressed because it is too large Load Diff

View File

@ -22,7 +22,7 @@ type Guild struct {
type GuildLog struct {
GuildId int64
AccountId string
LogType uint16
LogType int32
Content string
}

View File

@ -43,7 +43,7 @@ func (gm *GuildMgr) loadGuildFromDBResult(err error, rows *f5.DataSet) {
MaxMembers: maxMembers,
}
// push to gm.guilds
gm.Guilds[guildId] = newGuild
gm.guilds[guildId] = newGuild
// init pendingReqs
gm.pendingReqs[guildId] = make(map[string]bool)
}
@ -83,7 +83,7 @@ func (gm *GuildMgr) loadGuildMemberFromDBResult(err error, rows *f5.DataSet) {
AccountId: accountId,
Level: level,
}
if guild, ok := gm.Guilds[guildId]; ok {
if guild, ok := gm.guilds[guildId]; ok {
err := guild.AddMember(guildMember)
if err != nil {
f5.GetSysLog().Info("Guild:%d member is full\n", guildId)
@ -152,15 +152,15 @@ func (gm *GuildMgr) loadGuildLogsFromDBResult(err error, pagination *f5.Paginati
var (
guildId int64
accountId string
logType uint16
logType int32
content string
)
gm.Logs[guildId] = make([]*GuildLog, DefaultLogs)
gm.guildLogs[guildId] = make([]*GuildLog, DefaultLogs)
for pagination.Rows.Next() {
guildId = q5.ToInt64(*pagination.Rows.GetByIndex(0))
accountId = q5.ToString(*pagination.Rows.GetByIndex(1))
logType = uint16(q5.ToInt32(*pagination.Rows.GetByIndex(2)))
logType = q5.ToInt32(*pagination.Rows.GetByIndex(2))
content = q5.ToString(*pagination.Rows.GetByIndex(3))
guildLog := &GuildLog{
@ -169,7 +169,7 @@ func (gm *GuildMgr) loadGuildLogsFromDBResult(err error, pagination *f5.Paginati
LogType: logType,
Content: content,
}
gm.Logs[guildId] = append(gm.Logs[guildId], guildLog)
gm.guildLogs[guildId] = append(gm.guildLogs[guildId], guildLog)
}
q5.UnSetBitFlag(&gm.loadedFlags, LoadGuildLogFlag)
}

View File

@ -17,18 +17,18 @@ const (
type GuildMgr struct {
cs.MsgHandlerImpl
Guilds map[int64]*Guild // 公会ID -> 公会列表
guilds map[int64]*Guild // 公会ID -> 公会列表
pendingReqs map[int64]map[string]bool // 公会ID -> 申请者账户ID -> bool
Logs map[int64][]*GuildLog // 公会ID -> 公会日志
guildLogs map[int64][]*GuildLog // 公会ID -> 公会日志
loadedFlags int64
guildIds []int64 // 公会ids
}
func NewGuildMgr() *GuildMgr {
return &GuildMgr{
Guilds: make(map[int64]*Guild),
guilds: make(map[int64]*Guild),
pendingReqs: make(map[int64]map[string]bool),
Logs: make(map[int64][]*GuildLog),
guildLogs: make(map[int64][]*GuildLog),
}
}
@ -65,7 +65,7 @@ func (gm *GuildMgr) CreateGuild(name string, leaderId string) (int64, error) {
}
guildId := f5.GetApp().NewUuid()
if _, exists := gm.Guilds[guildId]; exists {
if _, exists := gm.guilds[guildId]; exists {
return 0, fmt.Errorf("CreateGuild fail")
}
@ -84,7 +84,7 @@ func (gm *GuildMgr) CreateGuild(name string, leaderId string) (int64, error) {
gm.createGuildDB(guild)
gm.upsertGuildMember(guildId, &newMember)
gm.Guilds[guildId] = guild
gm.guilds[guildId] = guild
gm.addGuildIds(guildId)
return guildId, nil
@ -179,8 +179,8 @@ func (gm *GuildMgr) Reject(guildId int64, applicantAccountId string) error {
// JoinGuild 直接加入公会
func (gm *GuildMgr) JoinGuild(guildId int64, accountId string) error {
guild, exists := gm.Guilds[guildId]
if !exists {
guild := gm.GetGuild(guildId)
if guild == nil {
return fmt.Errorf("guild not found")
}
@ -384,13 +384,14 @@ func (gm *GuildMgr) Disband(guildId int64, accountId string) error {
gm.updateAllPendingReqs(guildId, PendingReqIsJoinGuildStatusDisband)
guild.Members = nil
gm.Guilds[guildId] = nil
gm.guilds[guildId] = nil
gm.pendingReqs[guildId] = nil
gm.Logs[guildId] = nil
delete(gm.Guilds, guildId)
gm.guildLogs[guildId] = nil
delete(gm.guilds, guildId)
delete(gm.pendingReqs, guildId)
delete(gm.Logs, guildId)
delete(gm.guildLogs, guildId)
gm.RemoveGuildsId(guildId)
logContent := fmt.Sprintf("GuildDisbanded[%d-%s]", guildId, guildName)
gm.WriteLog(guildId, accountId, LogTypeDisband, logContent)
@ -398,16 +399,31 @@ func (gm *GuildMgr) Disband(guildId int64, accountId string) error {
return nil
}
func (gm *GuildMgr) RemoveGuildsId(guildId int64) {
guildIndex := -1
for i, gId := range gm.guildIds {
if gId == guildId {
guildIndex = i
}
}
if guildIndex < 0 {
return
}
copy(gm.guildIds[guildIndex:], gm.guildIds[guildIndex+1:])
gm.guildIds[len(gm.guildIds)-1] = 0
gm.guildIds = gm.guildIds[:len(gm.guildIds)-1]
}
// WriteLog 记录公会日志
func (gm *GuildMgr) WriteLog(guildId int64, accountId string, logType uint16, content string) {
func (gm *GuildMgr) WriteLog(guildId int64, accountId string, logType int32, content string) {
guild := gm.GetGuild(guildId)
if guild == nil {
return
}
_, exists := gm.Logs[guildId]
_, exists := gm.guildLogs[guildId]
if !exists {
gm.Logs[guildId] = make([]*GuildLog, DefaultLogs)
gm.guildLogs[guildId] = make([]*GuildLog, DefaultLogs)
}
log := &GuildLog{
GuildId: guildId,
@ -415,18 +431,18 @@ func (gm *GuildMgr) WriteLog(guildId int64, accountId string, logType uint16, co
LogType: logType,
Content: content,
}
gm.Logs[guildId] = append(gm.Logs[guildId], log)
gm.guildLogs[guildId] = append(gm.guildLogs[guildId], log)
gm.insertGuildLog(log)
}
func (gm *GuildMgr) GetLogs(guildID int64) []*GuildLog {
return gm.Logs[guildID]
return gm.guildLogs[guildID]
}
// SearchGuilds 根据关键字搜索公会
func (gm *GuildMgr) SearchGuilds(keyword string) []*Guild {
var results []*Guild
for _, guild := range gm.Guilds {
for _, guild := range gm.guilds {
if containsSubstring(guild.Name, keyword) {
results = append(results, guild)
}
@ -436,12 +452,12 @@ func (gm *GuildMgr) SearchGuilds(keyword string) []*Guild {
// RandomGuilds 随机10个公会
func (gm *GuildMgr) RandomGuilds() []*Guild {
count := len(gm.Guilds)
count := len(gm.guilds)
var results []*Guild
if count <= RandomGuildCount {
for _, guildId := range gm.guildIds {
results = append(results, gm.Guilds[guildId])
results = append(results, gm.guilds[guildId])
}
return results
}
@ -452,13 +468,13 @@ func (gm *GuildMgr) RandomGuilds() []*Guild {
}
for i := 0; i < RandomGuildCount; i++ {
randGuildId := gm.guildIds[i]
results = append(results, gm.Guilds[randGuildId])
results = append(results, gm.guilds[randGuildId])
}
return results
}
func (gm *GuildMgr) GetGuild(guildId int64) *Guild {
if guild, exists := gm.Guilds[guildId]; exists {
if guild, exists := gm.guilds[guildId]; exists {
return guild
}
return nil
@ -466,7 +482,7 @@ func (gm *GuildMgr) GetGuild(guildId int64) *Guild {
// GetGuildByAccountId 查询我的工会
func (gm *GuildMgr) GetGuildByAccountId(accountId string) *Guild {
for _, guild := range gm.Guilds {
for _, guild := range gm.guilds {
for _, member := range guild.Members {
if accountId == member.AccountId {
return guild
@ -484,7 +500,7 @@ func (gm *GuildMgr) Info(accountId string) (*Guild, map[string]bool, []*GuildLog
if guild != nil {
guildId := guild.GuildId
pendingReqs = gm.pendingReqs[guildId]
guildLogs = gm.Logs[guildId]
guildLogs = gm.guildLogs[guildId]
}
return guild, pendingReqs, guildLogs
@ -515,8 +531,8 @@ func (gm *GuildMgr) GetGuildIdByAccountId(accountId string) int64 {
}
func (gm *GuildMgr) loadGuildIds() {
gm.guildIds = make([]int64, 0, len(gm.Guilds))
for guildId, _ := range gm.Guilds {
gm.guildIds = make([]int64, 0, len(gm.guilds))
for guildId := range gm.guilds {
gm.guildIds = append(gm.guildIds, guildId)
}
}
@ -528,3 +544,17 @@ func (gm *GuildMgr) addGuildIds(guildId int64) {
func containsSubstring(s, substr string) bool {
return len(s) >= len(substr) && s[len(s)-len(substr):] == substr
}
func (gm *GuildMgr) GetAllPendingReqs(guildId int64) map[string]bool {
if pendingReq, exists := gm.pendingReqs[guildId]; exists {
return pendingReq
}
return nil
}
func (gm *GuildMgr) GetGuildLogs(guildId int64) []*GuildLog {
if logs, exists := gm.guildLogs[guildId]; exists {
return logs
}
return nil
}

View File

@ -328,7 +328,7 @@ func (p *Player) CMCreateGuild(hdr *f5.MsgHdr, msg *cs.CMCreateGuild) {
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
}
// CMApplyToGuild 同意申请者加入公会
// CMApplyToGuild 申请者加入公会
func (p *Player) CMApplyToGuild(hdr *f5.MsgHdr, msg *cs.CMApplyToGuild) {
rspMsg := new(cs.SMApplyToGuild)
err := guildMgr.ApplyToGuild(
@ -344,6 +344,22 @@ func (p *Player) CMApplyToGuild(hdr *f5.MsgHdr, msg *cs.CMApplyToGuild) {
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
}
// CMApplyList 请求申请者列表
func (p *Player) CMApplyList(hdr *f5.MsgHdr, msg *cs.CMApplyList) {
rspMsg := new(cs.SMApplyList)
guild := guildMgr.GetGuildByAccountId(p.accountId)
if guild == nil {
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
return
}
for accountId, isPending := range guildMgr.GetAllPendingReqs(guild.GetGuildId()) {
if isPending {
rspMsg.AccountId = append(rspMsg.AccountId, accountId)
}
}
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
}
// CMApprove 同意申请者加入公会
func (p *Player) CMApprove(hdr *f5.MsgHdr, msg *cs.CMApprove) {
rspMsg := new(cs.SMApprove)
@ -471,6 +487,26 @@ func (p *Player) CMSearchGuilds(hdr *f5.MsgHdr, msg *cs.CMSearchGuilds) {
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
}
// CMGuildLogs 请求公会日志
func (p *Player) CMGuildLogs(hdr *f5.MsgHdr, msg *cs.CMGuildLogs) {
rspMsg := new(cs.SMGuildLogs)
guild := guildMgr.GetGuildByAccountId(p.accountId)
if guild == nil {
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
return
}
for _, g := range guildMgr.GetGuildLogs(guild.GetGuildId()) {
guildLog := &cs.MFGuildLog{
GuildId: &g.GuildId,
AccountId: &g.AccountId,
LogType: &g.LogType,
Content: &g.Content,
}
rspMsg.GuildLogs = append(rspMsg.GuildLogs, guildLog)
}
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
}
// FillGuild 填充公共列表
func (p *Player) FillGuild(guilds []*Guild) []*cs.MFGuild {
var resGuilds []*cs.MFGuild

View File

@ -25,6 +25,8 @@ enum CMMessageId_e
//
_CMSetCurrPrivateChatTarget = 200;
_CMSendChatMsg = 201;
_CMReadMsgAndOpenChatNotify = 202;
_CMCloseChatNotify = 203;
//
@ -39,6 +41,8 @@ enum CMMessageId_e
_CMDemoteMember = 128;
_CMDisband = 129;
_CMSearchGuilds = 130;
_CMApplyList = 131;
_CMGuildLogs = 132;
}
enum SMMessageId_e
@ -72,8 +76,13 @@ enum SMMessageId_e
_SMDemoteMember = 128;
_SMDisband = 129;
_SMSearchGuilds = 130;
_SMApplyList = 131;
_SMGuildLogs = 132;
//
_SMUpdateChatRedPointNotify = 200;
_SMChatMsgNotify = 201;
_SMUpdateRedPointNotify = 202;
_SMUpdatePrivateChatRedPointNotify = 203;
_SMUpdateChatChannelLastId = 204;
}

View File

@ -365,19 +365,27 @@ message SMCreateGuild
optional string err_msg = 2;
}
//
message CMApplyToGuild
{
optional int64 guild_id = 1;
}
//
//
message SMApplyToGuild
{
optional string err_msg = 1;
}
//
message CMApplyList{}
//
message SMApplyList
{
repeated string account_id = 1;
}
//
message CMApprove
{
@ -391,14 +399,14 @@ message SMApprove
optional string err_msg = 1;
}
//
//
message CMReject
{
optional int64 guild_id = 1;
optional string applicant_account_id = 2;
}
//
//
message SMReject
{
optional string err_msg = 1;
@ -484,4 +492,20 @@ message MFGuild {
optional string leader_id = 3;
optional int32 members = 4;
optional int32 max_members = 5;
}
}
//
message CMGuildLogs{}
//
message SMGuildLogs
{
repeated MFGuildLog guildLogs = 1;
}
message MFGuildLog {
optional int64 guild_id = 1;
optional string account_id = 2;
optional int32 log_type = 3;
optional string content = 4;
}