From ca48d9150f3d22185d196b00496404adc574a9df Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sun, 28 Jun 2020 20:27:39 +0800 Subject: [PATCH] 1 --- server/imserver/gamelog.cc | 147 +++++++++++++++++++++++++++++++++++++ server/imserver/player.cc | 5 ++ server/imserver/player.h | 3 + 3 files changed, 155 insertions(+) diff --git a/server/imserver/gamelog.cc b/server/imserver/gamelog.cc index 32bc533..23d20c6 100644 --- a/server/imserver/gamelog.cc +++ b/server/imserver/gamelog.cc @@ -4,8 +4,16 @@ #include "framework/cpp/tglog.h" #include #include "player.h" + #include "app.h" +const char* const FRIEND_LOGIN_EVENT = "friend_login"; +const char* const FRIEND_LOGOUT_EVENT = "friend_logout"; +const char* const FRIEND_APPLY_EVENT = "friend_apply"; +const char* const FRIEND_REFUSE_EVENT = "friend_refuse"; +const char* const FRIEND_AGREE_EVENT = "friend_agree"; +const char* const FRIEND_DELETE_EVENT = "friend_delete"; + void GameLog::Init() { @@ -18,30 +26,169 @@ void GameLog::UnInit() void GameLog::Login(Player* hum) { + int game_id = f8::ExtractGameIdFromAccountId(hum->AccountId()); + std::string channel = a8::XValue(f8::ExtractChannelIdFromAccountId(hum->AccountId())); + a8::MutableXObject* prop = a8::MutableXObject::NewObject(); + prop->SetVal("channel", channel); + prop->SetVal("ad_channel", ""); + prop->SetVal("gameid", game_id); + prop->SetVal("account_id", hum->AccountId()); + prop->SetVal("account_register_utctime", hum->account_registertime); + prop->SetVal("account_register_date", a8::TimestampToDateTime(hum->account_registertime)); + prop->SetVal("nickname", hum->NickName()); + prop->SetVal("user_value1", a8::XValue(hum->myself.base_data.user_value1).GetString()); + prop->SetVal("user_value2", a8::XValue(hum->myself.base_data.user_value2).GetString()); + prop->SetVal("user_value3", a8::XValue(hum->myself.base_data.user_value3).GetString()); + prop->SetVal("server_instance_id", App::Instance()->instance_id); + + f8::TGLog::Instance()->AddTrackLog(game_id, + hum->AccountId(), + hum->ip_saddr, + FRIEND_LOGIN_EVENT, + prop); + + delete prop; + prop = nullptr; } void GameLog::Logout(Player* hum) { + int game_id = f8::ExtractGameIdFromAccountId(hum->AccountId()); + std::string channel = a8::XValue(f8::ExtractChannelIdFromAccountId(hum->AccountId())); + a8::MutableXObject* prop = a8::MutableXObject::NewObject(); + prop->SetVal("channel", channel); + prop->SetVal("ad_channel", ""); + prop->SetVal("gameid", game_id); + prop->SetVal("account_id", hum->AccountId()); + prop->SetVal("account_register_utctime", hum->account_registertime); + prop->SetVal("account_register_date", a8::TimestampToDateTime(hum->account_registertime)); + prop->SetVal("nickname", hum->NickName()); + prop->SetVal("user_value1", a8::XValue(hum->myself.base_data.user_value1).GetString()); + prop->SetVal("user_value2", a8::XValue(hum->myself.base_data.user_value2).GetString()); + prop->SetVal("user_value3", a8::XValue(hum->myself.base_data.user_value3).GetString()); + prop->SetVal("server_instance_id", App::Instance()->instance_id); + + f8::TGLog::Instance()->AddTrackLog(game_id, + hum->AccountId(), + hum->ip_saddr, + FRIEND_LOGOUT_EVENT, + prop); + + delete prop; + prop = nullptr; } void GameLog::FriendApply(Player* hum, const std::string& account_id) { + int game_id = f8::ExtractGameIdFromAccountId(hum->AccountId()); + std::string channel = a8::XValue(f8::ExtractChannelIdFromAccountId(hum->AccountId())); + a8::MutableXObject* prop = a8::MutableXObject::NewObject(); + prop->SetVal("channel", channel); + prop->SetVal("ad_channel", ""); + prop->SetVal("gameid", game_id); + prop->SetVal("account_id", hum->AccountId()); + prop->SetVal("account_register_utctime", hum->account_registertime); + prop->SetVal("account_register_date", a8::TimestampToDateTime(hum->account_registertime)); + prop->SetVal("nickname", hum->NickName()); + prop->SetVal("server_instance_id", App::Instance()->instance_id); + prop->SetVal("target_id", account_id); + + f8::TGLog::Instance()->AddTrackLog(game_id, + hum->AccountId(), + hum->ip_saddr, + FRIEND_APPLY_EVENT, + prop); + + delete prop; + prop = nullptr; } void GameLog::FriendRefuse(Player* hum, const std::string& account_id) { + int game_id = f8::ExtractGameIdFromAccountId(hum->AccountId()); + std::string channel = a8::XValue(f8::ExtractChannelIdFromAccountId(hum->AccountId())); + a8::MutableXObject* prop = a8::MutableXObject::NewObject(); + prop->SetVal("channel", channel); + prop->SetVal("ad_channel", ""); + prop->SetVal("gameid", game_id); + prop->SetVal("account_id", hum->AccountId()); + prop->SetVal("account_register_utctime", hum->account_registertime); + prop->SetVal("account_register_date", a8::TimestampToDateTime(hum->account_registertime)); + prop->SetVal("nickname", hum->NickName()); + prop->SetVal("user_value1", a8::XValue(hum->myself.base_data.user_value1).GetString()); + prop->SetVal("user_value2", a8::XValue(hum->myself.base_data.user_value2).GetString()); + prop->SetVal("user_value3", a8::XValue(hum->myself.base_data.user_value3).GetString()); + prop->SetVal("server_instance_id", App::Instance()->instance_id); + prop->SetVal("target_id", account_id); + + f8::TGLog::Instance()->AddTrackLog(game_id, + hum->AccountId(), + hum->ip_saddr, + FRIEND_REFUSE_EVENT, + prop); + + delete prop; + prop = nullptr; } void GameLog::FriendAgree(Player* hum, const std::string& account_id) { + int game_id = f8::ExtractGameIdFromAccountId(hum->AccountId()); + std::string channel = a8::XValue(f8::ExtractChannelIdFromAccountId(hum->AccountId())); + a8::MutableXObject* prop = a8::MutableXObject::NewObject(); + prop->SetVal("channel", channel); + prop->SetVal("ad_channel", ""); + prop->SetVal("gameid", game_id); + prop->SetVal("account_id", hum->AccountId()); + prop->SetVal("account_register_utctime", hum->account_registertime); + prop->SetVal("account_register_date", a8::TimestampToDateTime(hum->account_registertime)); + prop->SetVal("nickname", hum->NickName()); + prop->SetVal("user_value1", a8::XValue(hum->myself.base_data.user_value1).GetString()); + prop->SetVal("user_value2", a8::XValue(hum->myself.base_data.user_value2).GetString()); + prop->SetVal("user_value3", a8::XValue(hum->myself.base_data.user_value3).GetString()); + prop->SetVal("server_instance_id", App::Instance()->instance_id); + prop->SetVal("target_id", account_id); + + f8::TGLog::Instance()->AddTrackLog(game_id, + hum->AccountId(), + hum->ip_saddr, + FRIEND_AGREE_EVENT, + prop); + + delete prop; + prop = nullptr; } void GameLog::FriendDelete(Player* hum, const std::string& account_id) { + int game_id = f8::ExtractGameIdFromAccountId(hum->AccountId()); + std::string channel = a8::XValue(f8::ExtractChannelIdFromAccountId(hum->AccountId())); + a8::MutableXObject* prop = a8::MutableXObject::NewObject(); + prop->SetVal("channel", channel); + prop->SetVal("ad_channel", ""); + prop->SetVal("gameid", game_id); + prop->SetVal("account_id", hum->AccountId()); + prop->SetVal("account_register_utctime", hum->account_registertime); + prop->SetVal("account_register_date", a8::TimestampToDateTime(hum->account_registertime)); + prop->SetVal("nickname", hum->NickName()); + prop->SetVal("user_value1", a8::XValue(hum->myself.base_data.user_value1).GetString()); + prop->SetVal("user_value2", a8::XValue(hum->myself.base_data.user_value2).GetString()); + prop->SetVal("user_value3", a8::XValue(hum->myself.base_data.user_value3).GetString()); + prop->SetVal("server_instance_id", App::Instance()->instance_id); + prop->SetVal("target_id", account_id); + + f8::TGLog::Instance()->AddTrackLog(game_id, + hum->AccountId(), + hum->ip_saddr, + FRIEND_DELETE_EVENT, + prop); + + delete prop; + prop = nullptr; } diff --git a/server/imserver/player.cc b/server/imserver/player.cc index 502dbca..6fb7e3e 100644 --- a/server/imserver/player.cc +++ b/server/imserver/player.cc @@ -874,6 +874,11 @@ const std::string Player::SessionId() return role_data.session_id; } +const std::string Player::NickName() +{ + return myself.base_data.nickname; +} + int Player::GetFriendNum() { return friend_hash_.size(); diff --git a/server/imserver/player.h b/server/imserver/player.h index e7df6be..7136a08 100644 --- a/server/imserver/player.h +++ b/server/imserver/player.h @@ -18,6 +18,8 @@ class Player Friend myself; RoleData role_data; + long ip_saddr = 0; + int account_registertime = 0; public: void Init(); @@ -103,6 +105,7 @@ class Player const std::string AccountId(); const std::string SessionId(); + const std::string NickName(); int GetFriendNum(); private: