添加注释
This commit is contained in:
parent
a8d78d5480
commit
794880b644
|
@ -65,15 +65,15 @@ func CSChatMsgHandler(s *netlib.Session, packetid int, data interface{}, sid int
|
|||
} else { //私聊
|
||||
FriendUnreadMgrSington.DelFriendUnread(p.Platform, p.SnId, msg.GetMsg2Snid())
|
||||
pack.Content = content
|
||||
if !FriendMgrSington.IsFriend(p.Platform, p.SnId, msg.GetMsg2Snid()) {
|
||||
if !FriendMgrSingleton.IsFriend(p.Platform, p.SnId, msg.GetMsg2Snid()) {
|
||||
pack.OpRetCode = chat.OpResultCode_OPRC_Chat_NotFriend
|
||||
logger.Logger.Warn("CSChatMsgHandler not friend")
|
||||
} else {
|
||||
if FriendMgrSington.IsShield(p.Platform, msg.GetMsg2Snid(), p.SnId) { //对方有没有屏蔽发送者
|
||||
if FriendMgrSingleton.IsShield(p.Platform, msg.GetMsg2Snid(), p.SnId) { //对方有没有屏蔽发送者
|
||||
pack.OpRetCode = chat.OpResultCode_OPRC_Chat_IsShield
|
||||
logger.Logger.Warn("CSChatMsgHandler IsShield")
|
||||
}
|
||||
if FriendMgrSington.IsShield(p.Platform, p.SnId, msg.GetMsg2Snid()) { //有没有屏蔽对方
|
||||
if FriendMgrSingleton.IsShield(p.Platform, p.SnId, msg.GetMsg2Snid()) { //有没有屏蔽对方
|
||||
pack.OpRetCode = chat.OpResultCode_OPRC_Chat_Shield
|
||||
logger.Logger.Warn("CSChatMsgHandler Shield")
|
||||
}
|
||||
|
@ -117,11 +117,11 @@ func CSGetChatLogHandler(s *netlib.Session, packetid int, data interface{}, sid
|
|||
logger.Logger.Warn("CSGetChatLogHandler platform == nil")
|
||||
return nil
|
||||
}
|
||||
if !FriendMgrSington.IsFriend(p.Platform, p.SnId, msg.GetSnid()) {
|
||||
if !FriendMgrSingleton.IsFriend(p.Platform, p.SnId, msg.GetSnid()) {
|
||||
logger.Logger.Warn("CSGetChatLogHandler not friend")
|
||||
return nil
|
||||
}
|
||||
friendInfo := FriendMgrSington.GetFriendList(p.Platform, p.SnId)
|
||||
friendInfo := FriendMgrSingleton.GetFriendList(p.Platform, p.SnId)
|
||||
var bf *model.BindFriend
|
||||
if friendInfo != nil && len(friendInfo) != 0 {
|
||||
for _, friend := range friendInfo {
|
||||
|
@ -275,7 +275,7 @@ func CSReadChatMsgHandler(s *netlib.Session, packetid int, data interface{}, sid
|
|||
logger.Logger.Warn("CSReadChatMsgHandler platform == nil")
|
||||
return nil
|
||||
}
|
||||
if !FriendMgrSington.IsFriend(p.Platform, p.SnId, msg.GetSnid()) {
|
||||
if !FriendMgrSingleton.IsFriend(p.Platform, p.SnId, msg.GetSnid()) {
|
||||
logger.Logger.Warn("CSReadChatMsgHandler not friend")
|
||||
return nil
|
||||
}
|
||||
|
@ -307,21 +307,21 @@ func CSShieldMsgHandler(s *netlib.Session, packetid int, data interface{}, sid i
|
|||
OpRetCode: chat.OpResultCode_OPRC_Sucess,
|
||||
}
|
||||
if msg.GetShield() {
|
||||
if FriendMgrSington.IsShield(p.Platform, p.SnId, msg.GetShieldSnid()) {
|
||||
if FriendMgrSingleton.IsShield(p.Platform, p.SnId, msg.GetShieldSnid()) {
|
||||
logger.Logger.Warn("重复屏蔽")
|
||||
pack.OpRetCode = chat.OpResultCode_OPRC_Chat_ReShield
|
||||
}
|
||||
} else {
|
||||
if !FriendMgrSington.IsShield(p.Platform, p.SnId, msg.GetShieldSnid()) {
|
||||
if !FriendMgrSingleton.IsShield(p.Platform, p.SnId, msg.GetShieldSnid()) {
|
||||
logger.Logger.Warn("重复解除")
|
||||
pack.OpRetCode = chat.OpResultCode_OPRC_Chat_ReUnShield
|
||||
}
|
||||
}
|
||||
if pack.OpRetCode == chat.OpResultCode_OPRC_Sucess {
|
||||
if msg.GetShield() {
|
||||
FriendMgrSington.AddShield(p.Platform, p.SnId, msg.GetShieldSnid())
|
||||
FriendMgrSingleton.AddShield(p.Platform, p.SnId, msg.GetShieldSnid())
|
||||
} else {
|
||||
FriendMgrSington.DelShield(p.Platform, p.SnId, msg.GetShieldSnid())
|
||||
FriendMgrSingleton.DelShield(p.Platform, p.SnId, msg.GetShieldSnid())
|
||||
}
|
||||
}
|
||||
proto.SetDefaults(pack)
|
||||
|
|
|
@ -46,8 +46,8 @@ func (this *CSFriendListHandler) Process(s *netlib.Session, packetid int, data i
|
|||
OpRetCode: friend.OpResultCode_OPRC_Sucess,
|
||||
}
|
||||
switch msg.GetListType() {
|
||||
case ListType_Friend:
|
||||
dfl := FriendMgrSington.GetFriendList(p.Platform, p.GetSnId())
|
||||
case ListTypeFriend:
|
||||
dfl := FriendMgrSingleton.GetFriendList(p.Platform, p.GetSnId())
|
||||
if dfl != nil {
|
||||
for _, bf := range dfl {
|
||||
if bf.SnId == p.SnId {
|
||||
|
@ -62,7 +62,7 @@ func (this *CSFriendListHandler) Process(s *netlib.Session, packetid int, data i
|
|||
CreateTs: proto.Int64(bf.CreateTime),
|
||||
LogoutTs: proto.Int64(bf.LogoutTime),
|
||||
LastChatTs: proto.Int64(bf.CreateTime),
|
||||
IsShield: proto.Bool(FriendMgrSington.IsShield(p.Platform, p.SnId, bf.SnId)),
|
||||
IsShield: proto.Bool(FriendMgrSingleton.IsShield(p.Platform, p.SnId, bf.SnId)),
|
||||
RoleId: bf.RoleId,
|
||||
}
|
||||
fi.Online = false
|
||||
|
@ -80,7 +80,7 @@ func (this *CSFriendListHandler) Process(s *netlib.Session, packetid int, data i
|
|||
proto.SetDefaults(pack)
|
||||
p.SendToClient(int(friend.FriendPacketID_PACKET_SCFriendList), pack)
|
||||
logger.Logger.Trace("SCFriendListHandler:", pack)
|
||||
case ListType_Apply:
|
||||
case ListTypeApply:
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
ret, err := model.QueryFriendApplyBySnid(p.Platform, p.SnId)
|
||||
if err != nil {
|
||||
|
@ -113,7 +113,7 @@ func (this *CSFriendListHandler) Process(s *netlib.Session, packetid int, data i
|
|||
p.SendToClient(int(friend.FriendPacketID_PACKET_SCFriendList), pack)
|
||||
logger.Logger.Trace("SCFriendListHandler: ", pack)
|
||||
})).Start()
|
||||
case ListType_Recommend:
|
||||
case ListTypeRecommend:
|
||||
friends := PlayerMgrSington.RecommendFriendRule(p.Platform, p.SnId)
|
||||
for _, f := range friends {
|
||||
if f.Snid == p.SnId {
|
||||
|
@ -165,7 +165,7 @@ func (this *CSFriendOpHandler) Process(s *netlib.Session, packetid int, data int
|
|||
if destP.Roles != nil {
|
||||
roleId = int(destP.Roles.ModId)
|
||||
}
|
||||
FriendMgrSington.FriendOp(msg.OpCode, p, &model.BindFriend{
|
||||
FriendMgrSingleton.FriendOp(msg.OpCode, p, &model.BindFriend{
|
||||
SnId: destP.SnId,
|
||||
Platform: destP.Platform,
|
||||
Name: destP.Name,
|
||||
|
@ -194,7 +194,7 @@ func (this *CSFriendOpHandler) Process(s *netlib.Session, packetid int, data int
|
|||
if destPlayer.Roles != nil {
|
||||
roleId = int(destPlayer.Roles.ModId)
|
||||
}
|
||||
FriendMgrSington.FriendOp(msg.OpCode, p, &model.BindFriend{
|
||||
FriendMgrSingleton.FriendOp(msg.OpCode, p, &model.BindFriend{
|
||||
SnId: destPlayer.SnId,
|
||||
Platform: destPlayer.Platform,
|
||||
Name: destPlayer.Name,
|
||||
|
@ -325,7 +325,7 @@ func (this *CSInviteFriendHandler) Process(s *netlib.Session, packetid int, data
|
|||
return nil
|
||||
}
|
||||
//不是好友
|
||||
if !FriendMgrSington.IsFriend(p.Platform, p.SnId, friendSnid) {
|
||||
if !FriendMgrSingleton.IsFriend(p.Platform, p.SnId, friendSnid) {
|
||||
logger.Logger.Warn("CSInviteFriendHandler not friend")
|
||||
opRetCode = friend.OpResultCode_OPRC_InviteFriend_NotFriend
|
||||
send(p)
|
||||
|
@ -340,7 +340,7 @@ func (this *CSInviteFriendHandler) Process(s *netlib.Session, packetid int, data
|
|||
return nil
|
||||
}
|
||||
//CD
|
||||
if !FriendMgrSington.CanInvite(p.Platform, p.SnId, friendSnid) {
|
||||
if !FriendMgrSingleton.CanInvite(p.Platform, p.SnId, friendSnid) {
|
||||
logger.Logger.Warn("CSInviteFriendHandler in cd time")
|
||||
opRetCode = friend.OpResultCode_OPRC_Error
|
||||
send(p)
|
||||
|
@ -437,7 +437,7 @@ func (this *CSInviteFriendOpHandler) Process(s *netlib.Session, packetid int, da
|
|||
return nil
|
||||
}
|
||||
//不是好友
|
||||
if !FriendMgrSington.IsFriend(p.Platform, p.SnId, srcSnid) {
|
||||
if !FriendMgrSingleton.IsFriend(p.Platform, p.SnId, srcSnid) {
|
||||
logger.Logger.Warn("CSInviteFriendHandler not friend")
|
||||
opRetCode = friend.OpResultCode_OPRC_InviteFriend_NotFriend
|
||||
send(p)
|
||||
|
@ -445,7 +445,7 @@ func (this *CSInviteFriendOpHandler) Process(s *netlib.Session, packetid int, da
|
|||
}
|
||||
|
||||
switch int(opcode) {
|
||||
case Invite_Agree:
|
||||
case InviteAgree:
|
||||
logger.Logger.Trace("同意邀请")
|
||||
if p.scene != nil {
|
||||
logger.Logger.Warn("CSInviteFriendHandler scene is not nil")
|
||||
|
@ -574,7 +574,7 @@ func (this *CSInviteFriendOpHandler) Process(s *netlib.Session, packetid int, da
|
|||
}
|
||||
}
|
||||
}
|
||||
case Invite_Refuse:
|
||||
case InviteRefuse:
|
||||
logger.Logger.Trace("拒绝邀请")
|
||||
send(fp) //通知邀请者
|
||||
}
|
||||
|
@ -612,7 +612,7 @@ func (this *CSFuzzyQueryPlayerHandler) Process(s *netlib.Session, packetid int,
|
|||
|
||||
// 优先搜索在线玩家
|
||||
for _, player := range PlayerMgrSington.snidMap {
|
||||
if player != nil && player.IsOnLine() /*&& !player.IsRobot() && !FriendMgrSington.IsFriend(p.SnId, player.SnId)*/ { //在线
|
||||
if player != nil && player.IsOnLine() /*&& !player.IsRobot() && !FriendMgrSingleton.IsFriend(p.SnId, player.SnId)*/ { //在线
|
||||
if !player.IsRob && player.Platform != p.Platform { //不同平台的真人不能匹配
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -325,7 +325,7 @@ func (this *CSQueryRoomInfoHandler) ProcessLocalGame(s *netlib.Session, packetid
|
|||
|
||||
// 私人房需要是好友
|
||||
if scene.sceneMode == common.SceneModePrivate {
|
||||
if !FriendMgrSington.IsFriend(p.Platform, p.SnId, scene.creator) {
|
||||
if !FriendMgrSingleton.IsFriend(p.Platform, p.SnId, scene.creator) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ func (this *CSRisingStarHandler) Process(s *netlib.Session, packetid int, data i
|
|||
})
|
||||
//人物模型状态处理
|
||||
p.Roles.ModUnlock[msg.RisingModId]++
|
||||
FriendMgrSington.UpdateInfo(p.Platform, p.SnId)
|
||||
FriendMgrSingleton.UpdateInfo(p.Platform, p.SnId)
|
||||
p.dirty = true
|
||||
//人物
|
||||
SendInfoRole(pets.OpResultCode_OPRC_Sucess, ModelMgrSingleton.GetRoleInfo(p, msg.RisingModId))
|
||||
|
@ -213,7 +213,7 @@ func (this *CSRisingStarHandler) Process(s *netlib.Session, packetid int, data i
|
|||
Remark: remark,
|
||||
})
|
||||
p.Pets.ModUnlock[msg.RisingModId]++
|
||||
FriendMgrSington.UpdateInfo(p.Platform, p.SnId)
|
||||
FriendMgrSingleton.UpdateInfo(p.Platform, p.SnId)
|
||||
p.dirty = true
|
||||
//宠物
|
||||
SendInfoPet(pets.OpResultCode_OPRC_Sucess, ModelMgrSingleton.GetPetInfo(p, msg.RisingModId))
|
||||
|
@ -346,7 +346,7 @@ func (this *CSRolePetUnlockHandler) Process(s *netlib.Session, packetid int, dat
|
|||
if p.Roles.Mod[msg.UseModId].Ts == 0 {
|
||||
p.Roles.Mod[msg.UseModId].Ts = time.Now().Unix()
|
||||
}
|
||||
FriendMgrSington.UpdateInfo(p.Platform, p.SnId)
|
||||
FriendMgrSingleton.UpdateInfo(p.Platform, p.SnId)
|
||||
p.dirty = true
|
||||
logger.Logger.Trace("解锁人物", msg.UseModId)
|
||||
SendMsg(pets.OpResultCode_OPRC_Sucess, ModelMgrSingleton.GetRoleInfo(p, msg.UseModId), nil)
|
||||
|
@ -381,7 +381,7 @@ func (this *CSRolePetUnlockHandler) Process(s *netlib.Session, packetid int, dat
|
|||
if p.Pets.Mod[msg.UseModId].Ts == 0 {
|
||||
p.Pets.Mod[msg.UseModId].Ts = time.Now().Unix()
|
||||
}
|
||||
FriendMgrSington.UpdateInfo(p.Platform, p.SnId)
|
||||
FriendMgrSingleton.UpdateInfo(p.Platform, p.SnId)
|
||||
p.dirty = true
|
||||
logger.Logger.Trace("解锁宠物", msg.UseModId)
|
||||
SendMsg(pets.OpResultCode_OPRC_Sucess, nil, ModelMgrSingleton.GetPetInfo(p, msg.UseModId))
|
||||
|
|
|
@ -2172,9 +2172,9 @@ func CSQueryPlayer(s *netlib.Session, packetid int, data interface{}, sid int64)
|
|||
GameID: f.GameID,
|
||||
}
|
||||
//IsFriend
|
||||
pack.IsFriend = FriendMgrSington.IsFriend(p.Platform, p.SnId, f.SnId)
|
||||
pack.IsFriend = FriendMgrSingleton.IsFriend(p.Platform, p.SnId, f.SnId)
|
||||
//IsShield
|
||||
pack.IsShield = FriendMgrSington.IsShield(p.Platform, p.SnId, f.SnId)
|
||||
pack.IsShield = FriendMgrSingleton.IsShield(p.Platform, p.SnId, f.SnId)
|
||||
//Role
|
||||
roleInfo := f.Roles
|
||||
if roleInfo != nil {
|
||||
|
@ -2227,7 +2227,7 @@ func CSQueryPlayer(s *netlib.Session, packetid int, data interface{}, sid int64)
|
|||
p.SendToClient(int(player_proto.PlayerPacketID_PACKET_SC_QUERYPLAYER), pack)
|
||||
logger.Logger.Trace("SCQueryPlayerHandler ok: ", ok, " pack: ", pack)
|
||||
} else { // 真人去friend取信息
|
||||
friend := FriendMgrSington.GetPlayer(p.Platform, destSnId)
|
||||
friend := FriendMgrSingleton.GetPlayer(p.Platform, destSnId)
|
||||
if friend != nil {
|
||||
send(friend)
|
||||
} else {
|
||||
|
|
|
@ -148,7 +148,7 @@ func init() {
|
|||
|
||||
// 更新好友信息
|
||||
if param.ItemId == common.ItemIDVCard {
|
||||
FriendMgrSington.UpdateInfo(p.Platform, p.SnId)
|
||||
FriendMgrSingleton.UpdateInfo(p.Platform, p.SnId)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -18,37 +18,40 @@ import (
|
|||
"mongo.games.com/game/worldsrv/internal"
|
||||
)
|
||||
|
||||
// 列表类型
|
||||
const (
|
||||
ListType_Friend int32 = iota // 0.好友列表
|
||||
ListType_Apply // 1.申请列表
|
||||
ListType_Recommend // 2.推荐列表
|
||||
ListTypeFriend int32 = iota // 0.好友列表
|
||||
ListTypeApply // 1.申请列表
|
||||
ListTypeRecommend // 2.推荐列表
|
||||
)
|
||||
|
||||
// 好友操作
|
||||
const (
|
||||
OpType_Apply int32 = iota // 0.申请
|
||||
OpType_Agree // 1.同意
|
||||
OpType_Refuse // 2.拒绝
|
||||
OpType_Delete // 3.删除
|
||||
OpTypeApply int32 = iota // 0.申请,申请添加好友
|
||||
OpTypeAgree // 1.同意,同意添加好友
|
||||
OpTypeRefuse // 2.拒绝,拒绝添加好友
|
||||
OpTypeDelete // 3.删除,删除好友
|
||||
)
|
||||
|
||||
// 是否同意邀请进入游戏
|
||||
const (
|
||||
Invite_Agree int = iota // 0.同意
|
||||
Invite_Refuse // 1.拒绝
|
||||
InviteAgree int = iota // 0.同意
|
||||
InviteRefuse // 1.拒绝
|
||||
)
|
||||
|
||||
const FriendMaxNum = 200
|
||||
const ShieldMaxNum = 10000
|
||||
const FriendApplyMaxNum = 1000 //好友申请上限
|
||||
const FriendWrite = "FriendWrite"
|
||||
const FriendMaxNum = 200 // 好友最大数量
|
||||
const ShieldMaxNum = 10000 // 最大屏蔽人数
|
||||
const FriendApplyMaxNum = 1000 // 好友申请上限
|
||||
const FriendWrite = "FriendWrite" // 好友数据修改线程名称
|
||||
|
||||
var FriendMgrSington = &FriendMgr{
|
||||
var FriendMgrSingleton = &FriendMgr{
|
||||
FriendList: make(map[string]map[int32]*model.Friend),
|
||||
TsInviteCd: make(map[string]map[string]int64),
|
||||
}
|
||||
|
||||
type FriendMgr struct {
|
||||
FriendList map[string]map[int32]*model.Friend // 平台id:snid:好友信息
|
||||
TsInviteCd map[string]map[string]int64 // 平台id:snid:邀请cd时间
|
||||
TsInviteCd map[string]map[string]int64 // 平台id:邀请人id_被邀请人id:邀请cd时间
|
||||
}
|
||||
|
||||
func (this *FriendMgr) ModuleName() string {
|
||||
|
@ -84,6 +87,8 @@ func (this *FriendMgr) Del(platform string, snid int32) {
|
|||
}
|
||||
|
||||
// CanInvite 是否可以邀请,邀请冷却
|
||||
// snid 发起人
|
||||
// fsnid 被邀请人
|
||||
func (this *FriendMgr) CanInvite(platform string, snid, fsnid int32) bool {
|
||||
if this.TsInviteCd[platform] == nil {
|
||||
this.TsInviteCd[platform] = make(map[string]int64)
|
||||
|
@ -275,6 +280,10 @@ func (this *FriendMgr) ApplyList(platform string, snid int32) {
|
|||
if ret != nil && ret.ApplySnids != nil {
|
||||
pack := &friend.SCFriendApplyData{}
|
||||
for _, as := range ret.ApplySnids {
|
||||
p := PlayerMgrSington.GetPlayerBySnId(as.SnId)
|
||||
if p != nil {
|
||||
as.Name = p.Name
|
||||
}
|
||||
fa := &friend.FriendApply{
|
||||
Snid: proto.Int32(as.SnId),
|
||||
Name: proto.String(as.Name),
|
||||
|
@ -302,6 +311,7 @@ func (this *FriendMgr) ApplyList(platform string, snid int32) {
|
|||
}
|
||||
|
||||
// AddShield 屏蔽好友消息
|
||||
// snid屏蔽ssnid的消息
|
||||
func (this *FriendMgr) AddShield(platform string, snid, ssnid int32) {
|
||||
if this.FriendList[platform] == nil {
|
||||
return
|
||||
|
@ -382,16 +392,16 @@ func (this *FriendMgr) UpdateLogoutTime(platform string, snid int32) {
|
|||
|
||||
func (this *FriendMgr) FriendOp(opcode int32, p *Player, destP *model.BindFriend) {
|
||||
switch opcode {
|
||||
case OpType_Apply:
|
||||
case OpTypeApply:
|
||||
logger.Logger.Trace("@Apply friend", p.SnId, " -> ", destP.SnId)
|
||||
this.FriendApply(p, destP)
|
||||
case OpType_Agree:
|
||||
case OpTypeAgree:
|
||||
logger.Logger.Trace("@AgreeApply friend", p.SnId, " -> ", destP.SnId)
|
||||
this.FriendAgree(p, destP)
|
||||
case OpType_Refuse:
|
||||
case OpTypeRefuse:
|
||||
logger.Logger.Trace("@Refuse friend", p.SnId, " -> ", destP.SnId)
|
||||
this.FriendRefuse(p, destP)
|
||||
case OpType_Delete:
|
||||
case OpTypeDelete:
|
||||
logger.Logger.Trace("@Delete friend", p.SnId, " -> ", destP.SnId)
|
||||
this.FriendDelete(p, destP)
|
||||
}
|
||||
|
@ -399,11 +409,13 @@ func (this *FriendMgr) FriendOp(opcode int32, p *Player, destP *model.BindFriend
|
|||
|
||||
// FriendApply 好友申请
|
||||
// 记录在数据库
|
||||
// p 发起方
|
||||
// destP 接收方
|
||||
func (this *FriendMgr) FriendApply(p *Player, destP *model.BindFriend) {
|
||||
var applyList []int32
|
||||
SendToClick := func(retCode friend.OpResultCode, self ...bool) {
|
||||
pack := &friend.SCFriendOp{
|
||||
OpCode: proto.Int32(OpType_Apply),
|
||||
OpCode: proto.Int32(OpTypeApply),
|
||||
SnId: proto.Int32(destP.SnId),
|
||||
OpRetCode: retCode,
|
||||
}
|
||||
|
@ -435,7 +447,7 @@ func (this *FriendMgr) FriendApply(p *Player, destP *model.BindFriend) {
|
|||
}
|
||||
logger.Logger.Tracef(">>FriendApply %d -> %d, %v", p.SnId, destP.SnId, pack)
|
||||
}
|
||||
if FriendMgrSington.IsFriend(p.Platform, p.SnId, destP.SnId) {
|
||||
if FriendMgrSingleton.IsFriend(p.Platform, p.SnId, destP.SnId) {
|
||||
SendToClick(friend.OpResultCode_OPRC_Friend_AlreadyAdd)
|
||||
return
|
||||
}
|
||||
|
@ -496,11 +508,13 @@ func (this *FriendMgr) FriendApply(p *Player, destP *model.BindFriend) {
|
|||
}
|
||||
|
||||
// FriendAgree 同意好友申请
|
||||
// p 同意者
|
||||
// destP 申请者
|
||||
func (this *FriendMgr) FriendAgree(p *Player, destP *model.BindFriend) {
|
||||
var applyList []int32
|
||||
SendToClick := func(retCode friend.OpResultCode, self ...bool) {
|
||||
pack := &friend.SCFriendOp{
|
||||
OpCode: proto.Int32(OpType_Agree),
|
||||
OpCode: proto.Int32(OpTypeAgree),
|
||||
SnId: proto.Int32(destP.SnId),
|
||||
OpRetCode: retCode,
|
||||
}
|
||||
|
@ -546,12 +560,12 @@ func (this *FriendMgr) FriendAgree(p *Player, destP *model.BindFriend) {
|
|||
}
|
||||
logger.Logger.Tracef(">>FriendAgree %d -> %d, %v", p.SnId, destP.SnId, pack)
|
||||
}
|
||||
me := FriendMgrSington.GetPlayer(p.Platform, p.SnId)
|
||||
me := FriendMgrSingleton.GetPlayer(p.Platform, p.SnId)
|
||||
if me == nil {
|
||||
SendToClick(friend.OpResultCode_OPRC_Error)
|
||||
return
|
||||
}
|
||||
if FriendMgrSington.IsFriend(p.Platform, p.SnId, destP.SnId) { //已经是好友了
|
||||
if FriendMgrSingleton.IsFriend(p.Platform, p.SnId, destP.SnId) { //已经是好友了
|
||||
SendToClick(friend.OpResultCode_OPRC_Friend_AlreadyAdd)
|
||||
return
|
||||
}
|
||||
|
@ -561,7 +575,7 @@ func (this *FriendMgr) FriendAgree(p *Player, destP *model.BindFriend) {
|
|||
return
|
||||
}
|
||||
|
||||
destPFriend := FriendMgrSington.GetPlayer(destP.Platform, destP.SnId)
|
||||
destPFriend := FriendMgrSingleton.GetPlayer(destP.Platform, destP.SnId)
|
||||
if destPFriend != nil {
|
||||
if len(destPFriend.BindFriend) >= FriendMaxNum {
|
||||
SendToClick(friend.OpResultCode_OPRC_Friend_DestFriendMax)
|
||||
|
@ -569,7 +583,7 @@ func (this *FriendMgr) FriendAgree(p *Player, destP *model.BindFriend) {
|
|||
}
|
||||
}
|
||||
|
||||
var friendDB *model.Friend
|
||||
var friendDB *model.Friend // 申请者好友列表
|
||||
var err error
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
if destPFriend == nil {
|
||||
|
@ -598,15 +612,17 @@ func (this *FriendMgr) FriendAgree(p *Player, destP *model.BindFriend) {
|
|||
if err != nil {
|
||||
return friend.OpResultCode_OPRC_Error
|
||||
}
|
||||
// 维护申请放和被申请方的申请列表
|
||||
//查看是否在申请列表
|
||||
if ret != nil {
|
||||
if ret.ApplySnids != nil {
|
||||
for i, as := range ret.ApplySnids {
|
||||
if as.SnId == destP.SnId {
|
||||
//在申请列表 删除
|
||||
// 删除被申请者的申请列表
|
||||
ret.ApplySnids = append(ret.ApplySnids[:i], ret.ApplySnids[i+1:]...)
|
||||
model.UpsertFriendApply(p.Platform, p.SnId, ret)
|
||||
|
||||
// 删除发起方的申请列表
|
||||
data, err := model.QueryFriendApplyListBySnid(p.Platform, destP.SnId)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("QueryFriendApplyListBySnid err:%v", err)
|
||||
|
@ -646,12 +662,12 @@ func (this *FriendMgr) FriendAgree(p *Player, destP *model.BindFriend) {
|
|||
}
|
||||
|
||||
//同意者加入到被同意者好友里
|
||||
if destPlayer := FriendMgrSington.GetPlayer(destP.Platform, destP.SnId); destPlayer != nil {
|
||||
if destPlayer := FriendMgrSingleton.GetPlayer(destP.Platform, destP.SnId); destPlayer != nil {
|
||||
roleId := common.DefaultRoleId
|
||||
if p.Roles != nil {
|
||||
roleId = int(p.Roles.ModId)
|
||||
}
|
||||
result := FriendMgrSington.AgreeApply(destP.Platform, destP.SnId, &model.BindFriend{
|
||||
result := FriendMgrSingleton.AgreeApply(destP.Platform, destP.SnId, &model.BindFriend{
|
||||
SnId: p.SnId,
|
||||
CreateTime: time.Now().Unix(),
|
||||
Platform: p.Platform,
|
||||
|
@ -670,7 +686,7 @@ func (this *FriendMgr) FriendAgree(p *Player, destP *model.BindFriend) {
|
|||
}
|
||||
|
||||
// 被同意者加入到同意者好友里
|
||||
result := FriendMgrSington.AgreeApply(p.Platform, p.SnId, destP)
|
||||
result := FriendMgrSingleton.AgreeApply(p.Platform, p.SnId, destP)
|
||||
if result != friend.OpResultCode_OPRC_Sucess {
|
||||
SendToClick(result, false)
|
||||
SendToClick(result)
|
||||
|
@ -685,7 +701,7 @@ func (this *FriendMgr) FriendRefuse(p *Player, destP *model.BindFriend) {
|
|||
var applyList []int32
|
||||
SendToClick := func(retCode friend.OpResultCode, self ...bool) {
|
||||
pack := &friend.SCFriendOp{
|
||||
OpCode: proto.Int32(OpType_Refuse),
|
||||
OpCode: proto.Int32(OpTypeRefuse),
|
||||
SnId: proto.Int32(destP.SnId),
|
||||
OpRetCode: retCode,
|
||||
}
|
||||
|
@ -699,7 +715,7 @@ func (this *FriendMgr) FriendRefuse(p *Player, destP *model.BindFriend) {
|
|||
}
|
||||
logger.Logger.Tracef(">>FriendRefuse %d -> %d, %v", p.SnId, destP.SnId, pack)
|
||||
}
|
||||
if FriendMgrSington.IsFriend(p.Platform, p.SnId, destP.SnId) {
|
||||
if FriendMgrSingleton.IsFriend(p.Platform, p.SnId, destP.SnId) {
|
||||
SendToClick(friend.OpResultCode_OPRC_Friend_AlreadyAdd)
|
||||
return
|
||||
}
|
||||
|
@ -744,6 +760,7 @@ func (this *FriendMgr) FriendRefuse(p *Player, destP *model.BindFriend) {
|
|||
}
|
||||
SendToClick(friend.OpResultCode_OPRC_Sucess)
|
||||
|
||||
// 刷新发起者的申请好友列表
|
||||
destPs := PlayerMgrSington.GetPlayerBySnId(destP.SnId)
|
||||
if destPs != nil && destPs.IsOnLine() {
|
||||
if applyList != nil {
|
||||
|
@ -757,7 +774,7 @@ func (this *FriendMgr) FriendRefuse(p *Player, destP *model.BindFriend) {
|
|||
func (this *FriendMgr) FriendDelete(p *Player, destP *model.BindFriend) {
|
||||
SendToClick := func(retCode friend.OpResultCode, self ...bool) {
|
||||
pack := &friend.SCFriendOp{
|
||||
OpCode: proto.Int32(OpType_Delete),
|
||||
OpCode: proto.Int32(OpTypeDelete),
|
||||
SnId: proto.Int32(destP.SnId),
|
||||
OpRetCode: retCode,
|
||||
}
|
||||
|
@ -774,17 +791,17 @@ func (this *FriendMgr) FriendDelete(p *Player, destP *model.BindFriend) {
|
|||
}
|
||||
}
|
||||
}
|
||||
f := FriendMgrSington.GetPlayer(p.Platform, destP.SnId)
|
||||
f := FriendMgrSingleton.GetPlayer(p.Platform, destP.SnId)
|
||||
if f != nil {
|
||||
//发起者删除被删除者
|
||||
isok1 := FriendMgrSington.RemoveFriend(p.Platform, p.SnId, f.SnId)
|
||||
isok1 := FriendMgrSingleton.RemoveFriend(p.Platform, p.SnId, f.SnId)
|
||||
if !isok1 {
|
||||
logger.Logger.Warn("RemoveFriend error: ", p.SnId, " del friend:", f.SnId)
|
||||
SendToClick(friend.OpResultCode_OPRC_Error)
|
||||
return
|
||||
}
|
||||
//被删除者删除发起者
|
||||
isok2 := FriendMgrSington.RemoveFriend(f.Platform, f.SnId, p.SnId)
|
||||
isok2 := FriendMgrSingleton.RemoveFriend(f.Platform, f.SnId, p.SnId)
|
||||
if !isok2 {
|
||||
logger.Logger.Warn("RemoveFriend error: ", f.SnId, " del friend:", p.SnId)
|
||||
//删除失败不用通知
|
||||
|
@ -817,7 +834,7 @@ func (this *FriendMgr) FriendDelete(p *Player, destP *model.BindFriend) {
|
|||
return
|
||||
} else {
|
||||
//发起者删除被删除者
|
||||
isok1 := FriendMgrSington.RemoveFriend(p.Platform, p.SnId, destP.SnId)
|
||||
isok1 := FriendMgrSingleton.RemoveFriend(p.Platform, p.SnId, destP.SnId)
|
||||
if !isok1 {
|
||||
logger.Logger.Warn("RemoveFriend error: ", p.SnId, " del friend:", destP.SnId)
|
||||
//SendToClick(friend.OpResultCode_OPRC_Error)
|
||||
|
@ -875,6 +892,7 @@ func (this *FriendMgr) LoadAfter(platform string, snid int32) *internal.PlayerLo
|
|||
Snid: snid,
|
||||
}
|
||||
|
||||
// 查询好友列表
|
||||
friendDB, err := model.QueryFriendBySnid(platform, snid)
|
||||
if err != nil {
|
||||
logger.Logger.Error("QueryFriendBySnid:", err, snid)
|
||||
|
@ -886,6 +904,7 @@ func (this *FriendMgr) LoadAfter(platform string, snid int32) *internal.PlayerLo
|
|||
return ret
|
||||
}
|
||||
|
||||
// 查询好友信息
|
||||
var offSnID []int32
|
||||
for _, v := range friendDB.BindFriend {
|
||||
roleId := common.DefaultRoleId
|
||||
|
@ -1011,6 +1030,6 @@ func (this *FriendMgr) Release(platform string, snid int32) {
|
|||
}
|
||||
|
||||
func init() {
|
||||
module.RegisteModule(FriendMgrSington, time.Hour, 0)
|
||||
internal.RegisterPlayerLoad(FriendMgrSington)
|
||||
module.RegisteModule(FriendMgrSingleton, time.Hour, 0)
|
||||
internal.RegisterPlayerLoad(FriendMgrSingleton)
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ func (this *FriendUnreadMgr) CheckSendFriendUnreadData(platform string, snid int
|
|||
}
|
||||
pack := &friend.SCFriendUnreadData{}
|
||||
for cSnid, unreadNum := range ful {
|
||||
isFriend := FriendMgrSington.IsFriend(platform, snid, cSnid)
|
||||
isFriend := FriendMgrSingleton.IsFriend(platform, snid, cSnid)
|
||||
if isFriend {
|
||||
fu := &friend.FriendUnread{
|
||||
Snid: proto.Int32(cSnid),
|
||||
|
@ -135,7 +135,7 @@ func (this *FriendUnreadMgr) SaveFriendUnreadData(platform string, snid int32) {
|
|||
if ful, ok := this.FriendUnreadList[platform][snid]; ok {
|
||||
fu := model.NewFriendUnread(snid)
|
||||
for cSnid, unreadNum := range ful {
|
||||
if unreadNum > 0 && FriendMgrSington.IsFriend(platform, snid, cSnid) {
|
||||
if unreadNum > 0 && FriendMgrSingleton.IsFriend(platform, snid, cSnid) {
|
||||
us := &model.FriendUnreadSnid{
|
||||
SnId: cSnid,
|
||||
UnreadNum: int32(unreadNum),
|
||||
|
|
|
@ -395,7 +395,7 @@ func (this *Player) OnRehold() {
|
|||
//登录事件
|
||||
this.ReportLoginEvent()
|
||||
|
||||
FriendMgrSington.ApplyList(this.Platform, this.SnId)
|
||||
FriendMgrSingleton.ApplyList(this.Platform, this.SnId)
|
||||
FriendUnreadMgrSington.CheckSendFriendUnreadData(this.Platform, this.SnId)
|
||||
|
||||
if !this.IsRob {
|
||||
|
@ -1200,7 +1200,7 @@ func (this *Player) DropLine() {
|
|||
this.SendToGame(int(serverproto.SSPacketID_PACKET_WG_PLAYERDROPLINE), pack)
|
||||
}
|
||||
|
||||
FriendMgrSington.UpdateLogoutTime(this.Platform, this.SnId)
|
||||
FriendMgrSingleton.UpdateLogoutTime(this.Platform, this.SnId)
|
||||
PlayerMgrSington.DropPlayer(this)
|
||||
}
|
||||
|
||||
|
@ -1212,7 +1212,7 @@ func (this *Player) Logout() {
|
|||
}
|
||||
this.SendToClient(int(loginproto.LoginPacketID_PACKET_SC_LOGOUT), scLogout)
|
||||
|
||||
FriendMgrSington.UpdateLogoutTime(this.Platform, this.SnId)
|
||||
FriendMgrSingleton.UpdateLogoutTime(this.Platform, this.SnId)
|
||||
PlayerMgrSington.DropPlayer(this)
|
||||
}
|
||||
|
||||
|
@ -2006,7 +2006,7 @@ func (this *Player) SendDiffData() {
|
|||
}
|
||||
|
||||
if dirty {
|
||||
FriendMgrSington.UpdateInfo(this.Platform, this.SnId)
|
||||
FriendMgrSingleton.UpdateInfo(this.Platform, this.SnId)
|
||||
this.SendToClient(int(playerproto.PlayerPacketID_PACKET_SC_PLAYERDATAUPDATE), pack)
|
||||
logger.Logger.Trace("(this *Player) SendDiffData() ", pack)
|
||||
}
|
||||
|
|
|
@ -410,7 +410,7 @@ func (this *PlayerMgr) BroadcastMessageToPlatformWithHall(platform string, snid
|
|||
mgs := make(map[*netlib.Session][]*srvproto.MCSessionUnion)
|
||||
for _, p := range players {
|
||||
if p != nil && p.gateSess != nil && p.IsOnLine() && p.scene == nil {
|
||||
if FriendMgrSington.IsShield(p.Platform, p.SnId, snid) {
|
||||
if FriendMgrSingleton.IsShield(p.Platform, p.SnId, snid) {
|
||||
continue
|
||||
}
|
||||
mgs[p.gateSess] = append(mgs[p.gateSess], &srvproto.MCSessionUnion{
|
||||
|
@ -663,7 +663,7 @@ func (this *PlayerMgr) RecommendFriendRule(platform string, snid int32) []Recomm
|
|||
rets := []RecommendFriend{}
|
||||
players := this.playerOfPlatform[platform]
|
||||
for _, player := range players { //优先真人
|
||||
if player.SnId != snid && !FriendMgrSington.IsFriend(platform, snid, player.SnId) {
|
||||
if player.SnId != snid && !FriendMgrSingleton.IsFriend(platform, snid, player.SnId) {
|
||||
roleId := common.DefaultRoleId
|
||||
if player.Roles != nil {
|
||||
roleId = int(player.Roles.ModId)
|
||||
|
@ -734,8 +734,8 @@ func init() {
|
|||
PlayerSubjectSign.AttachHeadOutline(PlayerMgrSington)
|
||||
PlayerSubjectSign.AttachHeadUrl(PlayerMgrSington)
|
||||
|
||||
PlayerSubjectSign.AttachName(FriendMgrSington)
|
||||
PlayerSubjectSign.AttachHead(FriendMgrSington)
|
||||
PlayerSubjectSign.AttachName(FriendMgrSingleton)
|
||||
PlayerSubjectSign.AttachHead(FriendMgrSingleton)
|
||||
|
||||
// 定时器
|
||||
common.RegisterClockFunc(&common.ClockFunc{
|
||||
|
|
Loading…
Reference in New Issue