本文整理汇总了C++中ChatChannel::IsClientInChannel方法的典型用法代码示例。如果您正苦于以下问题:C++ ChatChannel::IsClientInChannel方法的具体用法?C++ ChatChannel::IsClientInChannel怎么用?C++ ChatChannel::IsClientInChannel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ChatChannel
的用法示例。
在下文中一共展示了ChatChannel::IsClientInChannel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CapitaliseName
ChatChannel *ChatChannelList::AddClientToChannel(std::string ChannelName, Client *c) {
if(!c) return nullptr;
if((ChannelName.length() > 0) && (isdigit(ChannelName[0]))) {
c->GeneralChannelMessage("The channel name can not begin with a number.");
return nullptr;
}
std::string NormalisedName, Password;
std::string::size_type Colon = ChannelName.find_first_of(":");
if(Colon == std::string::npos)
NormalisedName = CapitaliseName(ChannelName);
else {
NormalisedName = CapitaliseName(ChannelName.substr(0, Colon));
Password = ChannelName.substr(Colon + 1);
}
if((NormalisedName.length() > 64) || (Password.length() > 64)) {
c->GeneralChannelMessage("The channel name or password cannot exceed 64 characters.");
return nullptr;
}
_log(UCS__TRACE, "AddClient to channel [%s] with password [%s]", NormalisedName.c_str(), Password.c_str());
ChatChannel *RequiredChannel = FindChannel(NormalisedName);
if(!RequiredChannel)
RequiredChannel = CreateChannel(NormalisedName, c->GetName(), Password, false, 0);
if(RequiredChannel->GetMinStatus() > c->GetAccountStatus()) {
std::string Message = "You do not have the required account status to join channel " + NormalisedName;
c->GeneralChannelMessage(Message);
return nullptr;
}
if(RequiredChannel->IsClientInChannel(c))
return nullptr;
if(RequiredChannel->IsInvitee(c->GetName())) {
RequiredChannel->AddClient(c);
RequiredChannel->RemoveInvitee(c->GetName());
return RequiredChannel;
}
if(RequiredChannel->CheckPassword(Password) || RequiredChannel->IsOwner(c->GetName()) || RequiredChannel->IsModerator(c->GetName()) ||
c->IsChannelAdmin()) {
RequiredChannel->AddClient(c);
return RequiredChannel;
}
c->GeneralChannelMessage("Incorrect password for channel " + (NormalisedName));
return nullptr;
}