This commit is contained in:
aozhiwei 2020-06-18 13:35:45 +08:00
parent 1694f84233
commit a97a8a73b8
5 changed files with 61 additions and 1 deletions

View File

@ -285,6 +285,14 @@ void Player::_CMFriendAgree(f8::MsgHdr& hdr, const cs::CMFriendAgree& msg)
PlayerMgr::Instance()->WatchPlayer(friendobj);
SendMsg(respmsg);
MarkDirty();
#if 1
{
Player* hum = PlayerMgr::Instance()->GetPlayerByAccountId(friendobj->base_data.account_id);
if (hum) {
hum->AddFriend(&myself);
}
}
#endif
a8::XObject conn_info = DBEngine::Instance()->GetConnInfo(myself.crc32_code);
DBEngine::Instance()->ExecAsyncScript
@ -354,6 +362,14 @@ void Player::_CMFriendDelete(f8::MsgHdr& hdr, const cs::CMFriendDelete& msg)
if (p) {
friend_hash_.erase(msg.friend_id());
MarkDirty();
#if 1
{
Player* hum = PlayerMgr::Instance()->GetPlayerByAccountId(p->base_data.account_id);
if (hum) {
hum->RemoveFriend(p->base_data.account_id);
}
}
#endif
}
respmsg.set_friend_id(msg.friend_id());
SendMsg(respmsg);
@ -711,6 +727,32 @@ void Player::InternalSendSSMsg(const Friend& friend_data,
}
}
void Player::AddFriend(Friend* p)
{
if (!GetFriendById(p->base_data.account_id)) {
Friend* friendobj = new Friend;
*friendobj = *p;
friendobj->crc32_code = a8::openssl::Crc32
(
(unsigned char*)friendobj->base_data.account_id.data(),
friendobj->base_data.account_id.size()
);
friendobj->hum = this;
friend_hash_[friendobj->base_data.account_id] = friendobj;
PlayerMgr::Instance()->WatchPlayer(friendobj);
}
}
void Player::RemoveFriend(const std::string& account_id)
{
Friend* friendobj = GetFriendById(account_id);
if (friendobj) {
PlayerMgr::Instance()->UnWatchPlayer(friendobj);
friend_hash_.erase(account_id);
delete friendobj;
}
}
const std::string Player::AccountId()
{
return myself.base_data.account_id;

View File

@ -95,6 +95,8 @@ class Player
void NotifyOffline();
void NotifyUserInfoUpdate(Friend* friend_data);
void PushFriendList();
void AddFriend(Friend* friendobj);
void RemoveFriend(const std::string& account_id);
const std::string AccountId();

View File

@ -64,4 +64,5 @@ enum SMMessageId_e
_SMUserInfoUpdate = 502;
_SMCustomMsgNotify = 503;
_SMUserTempCustomDataUpdate = 504;
_SMDeleteFriendNotify = 505;
}

View File

@ -90,6 +90,9 @@ message CMUpdateUserInfo
optional int64 user_value1 = 50; //1
optional int64 user_value2 = 51; //2
optional int64 user_value3 = 52; //3
optional int32 delay_time = 100; //()
optional int32 delay_flag = 101; //(1-16)flag定时器覆盖
}
//
@ -324,6 +327,9 @@ message CMUpdateTempCustomData
*/
optional int32 update_type = 1; //
optional MFUserTempCustomData temp_custom_data = 2; //
optional int32 delay_time = 100; //()
optional int32 delay_flag = 101; //(1-16)flag定时器覆盖
}
///线
@ -357,6 +363,12 @@ message SMUserInfoUpdate
repeated MFUserInfo user_infos = 1; //
}
//a
message SMDeleteFriendNotify
{
repeated string user_list = 1; //
}
//
message SMUserTempCustomDataUpdate
{

View File

@ -115,11 +115,14 @@ DROP TABLE IF EXISTS `event`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `event` (
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
`account_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT '事件接受方id',
`sender_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT '事件发送方id',
`target_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT '事件接受方id',
`event_name` varchar(255) CHARACTER SET utf8 NOT NULL COMMENT '事件名',
`param1` tinyblob COMMENT 'param1',
`param2` tinyblob COMMENT 'param2',
`param3` tinyblob COMMENT 'param3',
`event_data` mediumblob COMMENT '事件数据',
`status` int(11) NOT NULL DEFAULT '0' COMMENT '0:未处理 1:已处理',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
PRIMARY KEY (`idx`),
KEY `account_id` (`account_id`)