relation/server/imserver/gamelog.cc
2020-10-12 14:47:22 +08:00

243 lines
9.3 KiB
C++

#include "precompile.h"
#include "gamelog.h"
#include "framework/cpp/utils.h"
#include "framework/cpp/tglog.h"
#include <a8/mutable_xobject.h>
#include "player.h"
#include "guild.h"
#include "app.h"
#include "cs_proto.pb.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()
{
}
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("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_APPLY_EVENT,
prop);
delete prop;
prop = nullptr;
}
void GameLog::FriendRefuse(Player* hum, long long db_idx, 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("db_idx", db_idx);
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, long long db_idx, 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("db_idx", db_idx);
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;
}
void GameLog::GuildCreate(Player* hum, long long guild_id, const std::string& guild_name)
{
}
void GameLog::GuildApply(Guild* guild, const cs::MFBaseUserData& base_data)
{
}
void GameLog::GuildRefuse(Guild* guild, GuildMember* sender, long long db_idx, const std::string& account_id)
{
}
void GameLog::GuildAgree(Guild* guild, GuildMember* sender, long long db_idx, const std::string& account_id)
{
}
void GameLog::GuildKick(Guild* guild, GuildMember* sender, const std::string& account_id)
{
}
void GameLog::GuildQuit(Guild* guild, GuildMember* sender)
{
}
void GameLog::GuildSetJob(Guild* guild, GuildMember* sender, int old_job)
{
}
void GameLog::GuildAgreeInvite(Guild* guild, GuildMember* sender)
{
}