当前位置: 首页>>代码示例>>C++>>正文


C++ ChatChannel类代码示例

本文整理汇总了C++中ChatChannel的典型用法代码示例。如果您正苦于以下问题:C++ ChatChannel类的具体用法?C++ ChatChannel怎么用?C++ ChatChannel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ChatChannel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getChannel

bool Chat::talkToChannel(Player* player, SpeakClasses type, const std::string& text, uint16_t channelId)
{
	ChatChannel *channel = getChannel(player, channelId);
	if(!channel)
		return false;

	switch(channelId){
		case 0x08:
		{
			//0x08 is the channelId of Help channel
			if(type == SPEAK_CHANNEL_Y && player->hasFlag(PlayerFlag_TalkOrangeHelpChannel)){
				type = SPEAK_CHANNEL_O;
			}
			break;
		}
		default:
		{
			break;
		}
	}

	if(channel->talk(player, type, text)){
		return true;
	}

	return false;
}
开发者ID:gianflogao,项目名称:divinity-ots,代码行数:27,代码来源:chat.cpp

示例2: getChannel

bool Chat::talkToChannel(Player* player, const SpeakClasses& type,
                         const std::string& text, const uint16_t& channelId)
{
	ChatChannel* channel = getChannel(player, channelId);

	if (!channel)
	{
		return false;
	}

	SpeakClasses speakType = type;

	switch (channelId)
	{
		case CHANNEL_HELP:
		{
			// Help channel
			if (speakType == SPEAK_CHANNEL_Y && player->hasFlag(PlayerFlag_TalkOrangeHelpChannel))
			{
				speakType = SPEAK_CHANNEL_O;
			}

			break;
		}
		// Players can't speak in these channels while they're level 1
		// Also, there is a delay of 2 minutes for trade and trade rook
		case CHANNEL_TRADE:
		case CHANNEL_TRADE_ROOK:
		case CHANNEL_RL_CHAT:
		case CHANNEL_GAME_CHAT:
		{
			if (!player->hasFlag(PlayerFlag_CannotBeMuted))
			{
				if (player->getLevel() < 2)
				{
					player->sendCancel("You may not speak into channels as long as you are on level 1.");
					return true;
				}
				else if ((channelId == CHANNEL_TRADE || channelId == CHANNEL_TRADE_ROOK) && player->hasCondition(CONDITION_TRADE_MUTED))
				{
					player->sendCancel("You may only place one offer in two minutes.");
					return true;
				}
			}

			break;
		}
		default:
		{
			break;
		}
	}

	if (channel->talk(player, speakType, text))
	{
		return true;
	}

	return false;
}
开发者ID:edubart,项目名称:otserv,代码行数:60,代码来源:chat.cpp

示例3: reply

void ChatHandler::handleListChannelUsersMessage(ChatClient &client,
                                                MessageIn &msg)
{
    MessageOut reply(CPMSG_LIST_CHANNELUSERS_RESPONSE);

    std::string channelName = msg.readString();
    ChatChannel *channel = chatChannelManager->getChannel(channelName);

    if (channel)
    {
        reply.writeString(channel->getName());

        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)));
        }

        client.send(reply);
    }

    // log transaction
    Transaction trans;
    trans.mCharacterId = client.characterId;
    trans.mAction = TRANS_CHANNEL_USERLIST;
    trans.mMessage = "";
    storage->addTransaction(trans);
}
开发者ID:Ablu,项目名称:invertika,代码行数:31,代码来源:chathandler.cpp

示例4: getChannelList

void Chat::removeUserFromAllChannels(Player* player)
{
	ChannelList list = getChannelList(player);

	while (!list.empty())
	{
		ChatChannel* channel = list.front();
		list.pop_front();
		channel->removeUser(player);

		if (channel->getOwner() == player->getGUID())
		{
			deleteChannel(player, channel->getId());
		}
	}

	for (NormalChannelMap::iterator it = m_normalChannels.begin(); it != m_normalChannels.end(); ++it)
	{
		it->second->removeUser(player);
	}

	for (GuildChannelMap::iterator it = m_guildChannels.begin(); it != m_guildChannels.end(); ++it)
	{
		it->second->removeUser(player);
	}
}
开发者ID:edubart,项目名称:otserv,代码行数:26,代码来源:chat.cpp

示例5: iterator

void ChatChannelList::SendAllChannels(Client *c) {

	if(!c) return;

	if(!c->CanListAllChannels()) {
		c->GeneralChannelMessage("You do not have permission to list all the channels.");
		return;
	}

	c->GeneralChannelMessage("All current channels:");

	int ChannelsInLine = 0;

	LinkedListIterator<ChatChannel*> iterator(ChatChannels);

	iterator.Reset();

	std::string Message;

	char CountString[10];

	while(iterator.MoreElements()) {

		ChatChannel *CurrentChannel = iterator.GetData();

		if(!CurrentChannel || (CurrentChannel->GetMinStatus() > c->GetAccountStatus())) {

			iterator.Advance();

			continue;
		}

		if(ChannelsInLine > 0)
			Message += ", ";

		sprintf(CountString, "(%i)", CurrentChannel->MemberCount(c->GetAccountStatus()));

		Message += CurrentChannel->GetName();

		Message += CountString;

		ChannelsInLine++;

		if(ChannelsInLine == 6) {

			c->GeneralChannelMessage(Message);

			ChannelsInLine = 0;

			Message.clear();
		}

		iterator.Advance();
	}

	if(ChannelsInLine > 0)
		c->GeneralChannelMessage(Message);

}
开发者ID:Derision,项目名称:Server,代码行数:59,代码来源:chatchannel.cpp

示例6: getChannel

ChatChannel* Chat::addUserToChannel(Player& player, uint16_t channelId)
{
	ChatChannel* channel = getChannel(player, channelId);
	if (channel && channel->addUser(player)) {
		return channel;
	}
	return NULL;
}
开发者ID:Alvaritos,项目名称:forgottenserver,代码行数:8,代码来源:chat.cpp

示例7: getChannel

ChatChannel* Chat::getChannel(Player* player, uint16_t channelId)
{
	#ifdef __DEBUG_CHAT__
	std::clog << "Chat::getChannel - getChannel id " << channelId << std::endl;
	#endif
	if(!player || player->isRemoved())
		return false;

	if(channelId == CHANNEL_GUILD)
	{
		GuildChannelMap::iterator git = m_guildChannels.find(player->getGuildId());
		if(git != m_guildChannels.end())
			return git->second;

		return NULL;
	}

	if(channelId == CHANNEL_PARTY)
	{
		if(player->getParty())
		{
			PartyChannelMap::iterator it = m_partyChannels.find(player->getParty());
			if(it != m_partyChannels.end())
				return it->second;
		}

		return NULL;
	}

	NormalChannelMap::iterator nit = m_normalChannels.find(channelId);
	if(nit != m_normalChannels.end())
	{
		#ifdef __DEBUG_CHAT__
		std::clog << "Chat::getChannel - found normal channel" << std::endl;
		#endif
		ChatChannel* tmpChannel = nit->second;
		if(!tmpChannel || !tmpChannel->hasFlag(CHANNELFLAG_ENABLED) || player->getAccess() < tmpChannel->getAccess()
			|| (!player->hasCustomFlag(PlayerCustomFlag_GamemasterPrivileges) && !tmpChannel->checkVocation(
			player->getVocationId())))
		{
			#ifdef __DEBUG_CHAT__
			std::clog << "Chat::getChannel - cannot access normal channel" << std::endl;
			#endif
			return NULL;
		}

		#ifdef __DEBUG_CHAT__
		std::clog << "Chat::getChannel - endpoint return" << std::endl;
		#endif
		return tmpChannel;
	}

	PrivateChannelMap::iterator pit = m_privateChannels.find(channelId);
	if(pit != m_privateChannels.end() && pit->second->isInvited(player))
		return pit->second;

	return NULL;
}
开发者ID:Codex-NG,项目名称:thecrystalserver,代码行数:58,代码来源:chat.cpp

示例8: getChannelList

void Chat::removeUserFromAllChannels(Player* player)
{
	ChannelList list = getChannelList(player);
	while(list.size()){
		ChatChannel *channel = list.front();
		list.pop_front();
			
		channel->removeUser(player);
		
		if(channel->getOwner() == player->getGUID())
			deleteChannel(player, channel->getId());
	}
}
开发者ID:gianflogao,项目名称:divinity-ots,代码行数:13,代码来源:chat.cpp

示例9: frag

void IOGuild::frag(Player* player, uint64_t deathId, const DeathList& list)
{
	Database* db = Database::getInstance();
	War_t war;

	std::stringstream s;
	for(DeathList::const_iterator it = list.begin(); it != list.end(); )
	{
		if(it->isLast())
			war = it->getWar();

		Creature* creature = it->getKillerCreature();
		if(it != list.begin())
		{
			++it;
			if(it == list.end())
				s << " and ";
			else
				s << ", ";
		}
		else
			++it;

		s << creature->getName();
	}

	std::string killers = s.str();
	s.str("");

	ChatChannel* channel = NULL;
	if((channel = g_chat.getChannel(player, CHANNEL_GUILD)))
	{
		s << "Guild member " << player->getName() << " was killed by " << killers << ". The new score is " << war.frags[
			war.type == WAR_GUILD] << ":" << war.frags[war.type] << " frags (limit " << war.limit << ").";
		channel->talk("", SPEAK_CHANNEL_RA, s.str());
	}

	s.str("");
	if((channel = g_chat.getChannel(list[0].getKillerCreature()->getPlayer(), CHANNEL_GUILD)))
	{
		s << "Opponent " << player->getName() << " was killed by " << killers << ". The new score is " << war.frags[
			war.type] << ":" << war.frags[war.type == WAR_GUILD] << " frags (limit " << war.limit << ").";
		channel->talk("", SPEAK_CHANNEL_RA, s.str());
	}

	DBQuery query;
	query << "INSERT INTO `guild_kills` (`guild_id`, `war_id`, `death_id`) VALUES (" << war.ids[war.type] << ", " << war.war << ", " << deathId << ");";
	db->query(query.str());
}
开发者ID:DSpeichert,项目名称:3777,代码行数:49,代码来源:ioguild.cpp

示例10: processMessage

void ChatServer::processMessage(ChannelThemeChanged *msg)
{
    QString channelName = msg->channel;
    QString theme = msg->theme;
    QString username = msg->username;
    ChatChannel channel = m_clientList.getChannel(channelName);
    channel.setTopic(theme);
    m_clientList.updateChannel(channel);
    sendMessageToChannel(channelName, msg);
    ChannelSystemMessage *newmsg = new ChannelSystemMessage();
    newmsg->channelName = channelName;
    newmsg->message = QString("%1 changed channel theme to \"%2\"")
                              .arg(username)
                              .arg(theme);
    emit channelLog(channelName, newmsg->message);
    emit updateTable("channels");
    sendMessageToChannel(channelName, newmsg);
    delete newmsg;
}
开发者ID:dirktao,项目名称:chat-server,代码行数:19,代码来源:ChatServer.cpp

示例11: serveFeed

/*!
 * Универсальный метод для отдачи тела фида.
 */
bool FeedHandler::serveFeed(ChatChannel channel, const QString &feedName)
{
  if (!ifMethodAllowed())
    return true;

  if (!channel || !channel->feeds().all().contains(feedName)) {
    setNoStore();
    m_response->writeHead(Tufao::HttpServerResponse::NOT_FOUND);
    m_response->end();
    return true;
  }

  FeedPtr feed = channel->feed(feedName);
  qint64 date  = feed->head().date();

  RestReplyCache &cache = m_cache[channel->id() + feedName.toUtf8()];
  if (cache.date != date) {
    cache.date = date;
    cache.etag = etag(date, m_path.toUtf8());

    cache.body = JSON::generate(feed->feed());
  }

  setLastModified(date);
  setETag(cache.etag);
  setNoCache();

  if (!ifModified(cache.etag)) {
    m_response->writeHead(Tufao::HttpServerResponse::NOT_MODIFIED);
    m_response->end();
    return true;
  }

  m_response->writeHead(Tufao::HttpServerResponse::OK);
  if (m_request->method() != "HEAD") {
    setContentLength(cache.body.size());
    m_response->end(cache.body);
  }
  else
    m_response->end();

  return true;
}
开发者ID:johnbolia,项目名称:schat,代码行数:46,代码来源:FeedHandler.cpp

示例12: pub

/*!
 * Внутренняя функция публикации изменений.
 */
void Net::pub(ChatChannel channel, const QString &path, const NetRecord &record)
{
  const ChatId id(channel->id());

  NetRecordMap &map = m_data[id];
  if (map.value(path).date == record.date)
    return;

  map.insert(path, record);
  broadcast(channel, path, record);
}
开发者ID:Artanomell,项目名称:schat,代码行数:14,代码来源:Net.cpp

示例13: handleModeChangeMessage

void ChatHandler::handleModeChangeMessage(ChatClient &client, MessageIn &msg)
{
    short channelId = msg.readShort();
    ChatChannel *channel = chatChannelManager->getChannel(channelId);

    if (channelId == 0 || !channel)
    {
        // invalid channel
        return;
    }

    if (channel->getUserMode(&client).find('o') == std::string::npos)
    {
        // invalid permissions
        return;
    }

    // get the user whos mode has been changed
    std::string user = msg.readString();

    // get the mode to change to
    unsigned char mode = msg.readByte();
    channel->setUserMode(getClient(user), mode);

    // set the info to pass to all channel clients
    std::stringstream info;
    info << client.characterName << ":" << user << ":" << mode;

    warnUsersAboutPlayerEventInChat(channel,
                    info.str(),
                    CHAT_EVENT_MODE_CHANGE);

    // log transaction
    Transaction trans;
    trans.mCharacterId = client.characterId;
    trans.mAction = TRANS_CHANNEL_MODE;
    trans.mMessage = "User mode ";
    trans.mMessage.append(mode + " set on " + user);
    storage->addTransaction(trans);
}
开发者ID:Ablu,项目名称:invertika,代码行数:40,代码来源:chathandler.cpp

示例14: reply

void ChatHandler::handleGuildAcceptInvite(ChatClient &client,
                                          MessageIn &msg)
{
    MessageOut reply(CPMSG_GUILD_ACCEPT_RESPONSE);
    const int guildId = msg.readInt16();
    const bool accepted = msg.readInt8();

    // check guild exists and that member was invited
    // then add them as guild member
    // and remove from invite list
    Guild *guild = guildManager->findById(guildId);
    if (!(guild && guild->checkInvited(client.characterId)))
    {

        reply.writeInt8(ERRMSG_FAILURE);
    }
    else if (accepted)
    {
        // add user to guild
        guildManager->addGuildMember(guild, client.characterId);
        client.guilds.push_back(guild);
        reply.writeInt8(ERRMSG_OK);
        reply.writeString(guild->getName());
        reply.writeInt16(guild->getId());
        reply.writeInt16(guild->getUserPermissions(client.characterId));

        // have character join guild channel
        ChatChannel *channel = joinGuildChannel(guild->getName(), client);
        reply.writeInt16(channel->getId());
        sendGuildListUpdate(guild, client.characterName,
                            GUILD_EVENT_NEW_PLAYER);
    }
    else
    {
        guild->removeInvited(client.characterId);
        reply.writeInt8(ERRMSG_OK);
    }

    client.send(reply);
}
开发者ID:Ablu,项目名称:manaserv,代码行数:40,代码来源:guildhandler.cpp

示例15: count

ChannelIndexData::ChannelIndexData(ChatChannel channel)
  : count(0)
  , options(NoOptions)
  , visibility(0)
  , name(channel->name())
{
  FeedPtr feed = channel->feed(FEED_NAME_INFO, false);
  if (!feed)
    return;

  visibility = feed->data().value(INFO_FEED_VISIBILITY_KEY, 0).toInt();
  if (visibility < 0)
    return;

  if (channel->permanent())
    options |= Permanent;

  id    = channel->id();
  count = channel->channels().size();
  title = feed->data().value(INFO_FEED_TITLE_KEY).toMap().value(INFO_FEED_TEXT_KEY).toString();

  if (feed->data().value(INFO_FEED_PINNED_KEY, false).toBool())
    options |= Pinned;

  FeedPtr acl = channel->feed(FEED_NAME_ACL, false);
  if (acl && AclValue::match(acl.data(), 0) == 0)
    options |= Private;
}
开发者ID:johnbolia,项目名称:schat,代码行数:28,代码来源:NodeChannelIndex.cpp


注:本文中的ChatChannel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。