本文整理汇总了C++中Channel::ForceJoin方法的典型用法代码示例。如果您正苦于以下问题:C++ Channel::ForceJoin方法的具体用法?C++ Channel::ForceJoin怎么用?C++ Channel::ForceJoin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Channel
的用法示例。
在下文中一共展示了Channel::ForceJoin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleRemote
CmdResult CommandIJoin::HandleRemote(RemoteUser* user, std::vector<std::string>& params)
{
Channel* chan = ServerInstance->FindChan(params[0]);
if (!chan)
{
// Desync detected, recover
// Ignore the join and send RESYNC, this will result in the remote server sending all channel data to us
ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Received IJOIN for non-existant channel: " + params[0]);
CmdBuilder("RESYNC").push(params[0]).Unicast(user);
return CMD_FAILURE;
}
bool apply_modes;
if (params.size() > 2)
{
time_t RemoteTS = ServerCommand::ExtractTS(params[2]);
if (RemoteTS < chan->age)
throw ProtocolException("Attempted to lower TS via IJOIN. LocalTS=" + ConvToStr(chan->age));
apply_modes = ((params.size() > 3) && (RemoteTS == chan->age));
}
else
apply_modes = false;
// Join the user and set the membership id to what they sent
Membership* memb = chan->ForceJoin(user, apply_modes ? ¶ms[3] : NULL);
if (!memb)
return CMD_FAILURE;
memb->id = Membership::IdFromString(params[1]);
return CMD_SUCCESS;
}
示例2: HandleRemote
CmdResult CommandIJoin::HandleRemote(RemoteUser* user, std::vector<std::string>& params)
{
Channel* chan = ServerInstance->FindChan(params[0]);
if (!chan)
{
// Desync detected, recover
// Ignore the join and send RESYNC, this will result in the remote server sending all channel data to us
ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Received IJOIN for non-existant channel: " + params[0]);
CmdBuilder("RESYNC").push(params[0]).Unicast(user);
return CMD_FAILURE;
}
bool apply_modes;
if (params.size() > 1)
{
time_t RemoteTS = ConvToInt(params[1]);
if (!RemoteTS)
{
ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Invalid TS in IJOIN: " + params[1]);
return CMD_INVALID;
}
if (RemoteTS < chan->age)
{
ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Attempted to lower TS via IJOIN. Channel=" + params[0] + " RemoteTS=" + params[1] + " LocalTS=" + ConvToStr(chan->age));
return CMD_INVALID;
}
apply_modes = ((params.size() > 2) && (RemoteTS == chan->age));
}
else
apply_modes = false;
chan->ForceJoin(user, apply_modes ? ¶ms[2] : NULL);
return CMD_SUCCESS;
}