1
This commit is contained in:
parent
558793991c
commit
362de597bb
@ -27,9 +27,13 @@ class IMConn
|
|||||||
bool Connected();
|
bool Connected();
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void SendMsg(int socket_handle, T& msg)
|
void SendMsg(T& msg)
|
||||||
{
|
{
|
||||||
static int msgid = f8::Net_GetMessageId(msg);
|
static int msgid = f8::Net_GetMessageId(msg);
|
||||||
|
SendMsg(tcp_client_, msgid, msg);
|
||||||
|
}
|
||||||
|
void SendMsg(int msgid, ::google::protobuf::Message& msg)
|
||||||
|
{
|
||||||
f8::Net_SendMsg(tcp_client_, 0, msgid, msg);
|
f8::Net_SendMsg(tcp_client_, 0, msgid, msg);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
f8::DumpMsgToLog(msg, "<<<<<<<IMC ");
|
f8::DumpMsgToLog(msg, "<<<<<<<IMC ");
|
||||||
|
@ -13,6 +13,9 @@
|
|||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include "typeconvert.h"
|
#include "typeconvert.h"
|
||||||
|
|
||||||
|
#include "IMConn.h"
|
||||||
|
#include "IMConnMgr.h"
|
||||||
|
|
||||||
void Player::Init()
|
void Player::Init()
|
||||||
{
|
{
|
||||||
crc32_code = a8::openssl::Crc32(
|
crc32_code = a8::openssl::Crc32(
|
||||||
@ -119,29 +122,29 @@ void Player::_CMFriendApply(f8::MsgHdr& hdr, const cs::CMFriendApply& msg)
|
|||||||
msg.friend_id().size()
|
msg.friend_id().size()
|
||||||
);
|
);
|
||||||
a8::XObject conn_info = DBEngine::Instance()->GetConnInfo(friend_crc32_code);
|
a8::XObject conn_info = DBEngine::Instance()->GetConnInfo(friend_crc32_code);
|
||||||
DBEngine::Instance()->
|
DBEngine::Instance()->ExecAsyncScript
|
||||||
ExecAsyncScript(
|
(
|
||||||
conn_info,
|
conn_info,
|
||||||
"INSERT INTO `friend_apply`(applyid, target_id, sender_id, sender_nickmake, "
|
"INSERT INTO `friend_apply`(applyid, target_id, sender_id, sender_nickmake, "
|
||||||
" sender_avatar_url, sender_sex, sender_group_id, sender_data_version1, "
|
" sender_avatar_url, sender_sex, sender_group_id, sender_data_version1, "
|
||||||
" createtime)"
|
" createtime)"
|
||||||
"VALUES(%d, '%s', '%s', '%s', '%s', %d, %d, %d, %d);",
|
"VALUES(%d, '%s', '%s', '%s', '%s', %d, %d, %d, %d);",
|
||||||
{
|
{
|
||||||
App::Instance()->NewUUID(),
|
App::Instance()->NewUUID(),
|
||||||
msg.friend_id(),
|
msg.friend_id(),
|
||||||
data.base_data.account_id,
|
data.base_data.account_id,
|
||||||
data.base_data.nickname,
|
data.base_data.nickname,
|
||||||
data.base_data.avatar_url,
|
data.base_data.avatar_url,
|
||||||
data.base_data.sex,
|
data.base_data.sex,
|
||||||
data.base_data.group_id,
|
data.base_data.group_id,
|
||||||
data.base_data.data_version1,
|
data.base_data.data_version1,
|
||||||
App::Instance()->nowtime
|
App::Instance()->nowtime
|
||||||
},
|
},
|
||||||
a8::XParams(),
|
a8::XParams(),
|
||||||
on_ok,
|
on_ok,
|
||||||
on_error,
|
on_error,
|
||||||
friend_crc32_code
|
friend_crc32_code
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,24 +201,24 @@ void Player::_CMFriendApplyList(f8::MsgHdr& hdr, const cs::CMFriendApplyList& ms
|
|||||||
cs::MFPaging* paging_copy = nullptr;
|
cs::MFPaging* paging_copy = nullptr;
|
||||||
*paging_copy = msg.paging();
|
*paging_copy = msg.paging();
|
||||||
a8::XObject conn_info = DBEngine::Instance()->GetConnInfo(crc32_code);
|
a8::XObject conn_info = DBEngine::Instance()->GetConnInfo(crc32_code);
|
||||||
DBEngine::Instance()->
|
DBEngine::Instance()->ExecAsyncScript
|
||||||
ExecAsyncScript(
|
(
|
||||||
conn_info,
|
conn_info,
|
||||||
"SELECT idx, applyid, target_id, sender_id, sender_nickname, "
|
"SELECT idx, applyid, target_id, sender_id, sender_nickname, "
|
||||||
" sender_avatar_url, sender_sex, sender_group_id, sender_data_version1 "
|
" sender_avatar_url, sender_sex, sender_group_id, sender_data_version1 "
|
||||||
"FROM friend_apply WHERE %d > idx AND target_id='%s';",
|
"FROM friend_apply WHERE %d > idx AND target_id='%s';",
|
||||||
{
|
{
|
||||||
last_apply_idx_,
|
last_apply_idx_,
|
||||||
data.base_data.account_id
|
data.base_data.account_id
|
||||||
},
|
},
|
||||||
a8::XParams()
|
a8::XParams()
|
||||||
.SetSender(data.base_data.account_id)
|
.SetSender(data.base_data.account_id)
|
||||||
.SetParam1(hdr.socket_handle)
|
.SetParam1(hdr.socket_handle)
|
||||||
.SetParam2(paging_copy),
|
.SetParam2(paging_copy),
|
||||||
on_ok,
|
on_ok,
|
||||||
on_error,
|
on_error,
|
||||||
crc32_code
|
crc32_code
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::_CMFriendAgree(f8::MsgHdr& hdr, const cs::CMFriendAgree& msg)
|
void Player::_CMFriendAgree(f8::MsgHdr& hdr, const cs::CMFriendAgree& msg)
|
||||||
@ -514,22 +517,69 @@ void Player::NotifyOffline()
|
|||||||
|
|
||||||
void Player::OnDataVersion1Change()
|
void Player::OnDataVersion1Change()
|
||||||
{
|
{
|
||||||
|
if (!update_user_info_timer_) {
|
||||||
|
update_user_info_timer_ = a8::Timer::Instance()->AddDeadLineTimerAndAttach
|
||||||
|
(
|
||||||
|
1000 * 3,
|
||||||
|
a8::XParams()
|
||||||
|
.SetSender(this),
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
Player* hum = (Player*)param.sender.GetUserData();
|
||||||
|
hum->InternalUpdateUserInfo();
|
||||||
|
},
|
||||||
|
&timer_attacher.timer_list_,
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
Player* hum = (Player*)param.sender.GetUserData();
|
||||||
|
hum->update_user_info_timer_ = nullptr;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::OnTempCustomDataChange()
|
void Player::OnTempCustomDataChange()
|
||||||
{
|
{
|
||||||
|
if (!update_user_info_timer_) {
|
||||||
|
update_user_info_timer_ = a8::Timer::Instance()->AddDeadLineTimerAndAttach
|
||||||
|
(
|
||||||
|
1000 * 3,
|
||||||
|
a8::XParams()
|
||||||
|
.SetSender(this),
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
Player* hum = (Player*)param.sender.GetUserData();
|
||||||
|
hum->InternalUpdateUserInfo();
|
||||||
|
},
|
||||||
|
&timer_attacher.timer_list_,
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
Player* hum = (Player*)param.sender.GetUserData();
|
||||||
|
hum->update_user_info_timer_ = nullptr;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::InternalSendSSMsg(const Friend& friend_data,
|
void Player::InternalSendSSMsg(const Friend& friend_data,
|
||||||
int msgid,
|
int msgid,
|
||||||
::google::protobuf::Message& msg)
|
::google::protobuf::Message& msg)
|
||||||
{
|
{
|
||||||
|
if (friend_data.server_key.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
IMConn* conn = IMConnMgr::Instance()->GetConnByKey(friend_data.server_key);
|
||||||
|
if (conn) {
|
||||||
|
conn->SendMsg(msgid, msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string Player::AccountId()
|
const std::string Player::AccountId()
|
||||||
{
|
{
|
||||||
return data.base_data.account_id;
|
return data.base_data.account_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::InternalUpdateUserInfo()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -109,10 +109,12 @@ private:
|
|||||||
void InternalSendSSMsg(const Friend& friend_data,
|
void InternalSendSSMsg(const Friend& friend_data,
|
||||||
int msgid,
|
int msgid,
|
||||||
::google::protobuf::Message& msg);
|
::google::protobuf::Message& msg);
|
||||||
|
void InternalUpdateUserInfo();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool dirty_ = false;
|
bool dirty_ = false;
|
||||||
timer_list* dirty_timer_ = nullptr;
|
timer_list* dirty_timer_ = nullptr;
|
||||||
|
timer_list* update_user_info_timer_ = nullptr;
|
||||||
long long last_apply_idx_ = 0;
|
long long last_apply_idx_ = 0;
|
||||||
|
|
||||||
std::map<std::string, Friend> friend_hash_;
|
std::map<std::string, Friend> friend_hash_;
|
||||||
|
@ -30,7 +30,8 @@ struct Friend
|
|||||||
|
|
||||||
std::string server_host;
|
std::string server_host;
|
||||||
int server_port;
|
int server_port;
|
||||||
long long server_ident = 0;
|
std::string server_key;
|
||||||
|
long long server_instance_id = 0;
|
||||||
|
|
||||||
unsigned int crc32_code = 0;
|
unsigned int crc32_code = 0;
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package ss;
|
package ss;
|
||||||
|
|
||||||
|
import "cs_proto.proto";
|
||||||
|
|
||||||
message MFIMMsgConext
|
message MFIMMsgConext
|
||||||
{
|
{
|
||||||
optional string account_id = 1; //账号id
|
optional string account_id = 1; //账号id
|
||||||
@ -171,3 +173,8 @@ message SS_IM_IMServerList
|
|||||||
message SS_MS_IMServerList
|
message SS_MS_IMServerList
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message SS_IM_UpdateUserInfo
|
||||||
|
{
|
||||||
|
optional cs.MFUserInfo user_info = 1;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user