本文整理汇总了C++中ChatChannel::getPassword方法的典型用法代码示例。如果您正苦于以下问题:C++ ChatChannel::getPassword方法的具体用法?C++ ChatChannel::getPassword怎么用?C++ ChatChannel::getPassword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ChatChannel
的用法示例。
在下文中一共展示了ChatChannel::getPassword方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleEnterChannelMessage
void ChatHandler::handleEnterChannelMessage(ChatClient &client, MessageIn &msg)
{
MessageOut reply(CPMSG_ENTER_CHANNEL_RESPONSE);
std::string channelName = msg.readString();
std::string givenPassword = msg.readString();
ChatChannel *channel = NULL;
if (chatChannelManager->channelExists(channelName) ||
chatChannelManager->tryNewPublicChannel(channelName))
{
channel = chatChannelManager->getChannel(channelName);
}
if (!channel)
{
reply.writeByte(ERRMSG_INVALID_ARGUMENT);
}
else if (!channel->getPassword().empty() &&
channel->getPassword() != givenPassword)
{
// Incorrect password (should probably have its own return value)
reply.writeByte(ERRMSG_INSUFFICIENT_RIGHTS);
}
else if (!channel->canJoin())
{
reply.writeByte(ERRMSG_INVALID_ARGUMENT);
}
else
{
if (channel->addUser(&client))
{
reply.writeByte(ERRMSG_OK);
// The user entered the channel, now give him the channel
// id, the announcement string and the user list.
reply.writeShort(channel->getId());
reply.writeString(channelName);
reply.writeString(channel->getAnnouncement());
const ChatChannel::ChannelUsers &users = channel->getUserList();
for (ChatChannel::ChannelUsers::const_iterator i = users.begin(),
i_end = users.end();
i != i_end; ++i)
{
reply.writeString((*i)->characterName);
reply.writeString(channel->getUserMode((*i)));
}
// Send an CPMSG_UPDATE_CHANNEL to warn other clients a user went
// in the channel.
warnUsersAboutPlayerEventInChat(channel,
client.characterName,
CHAT_EVENT_NEW_PLAYER);
// log transaction
Transaction trans;
trans.mCharacterId = client.characterId;
trans.mAction = TRANS_CHANNEL_JOIN;
trans.mMessage = "User joined " + channelName;
storage->addTransaction(trans);
}
else
{
reply.writeByte(ERRMSG_FAILURE);
}
}
client.send(reply);
}