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


C++ ChatRoom类代码示例

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


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

示例1: createRoom

void ChatManagerImplementation::initiateRooms() {
	gameRooms.setNullValue(NULL);

	ChatRoom* mainRoom = createRoom("SWG");
	mainRoom->setPrivate();
	gameRooms.put("SWG", mainRoom);

	core3Room = createRoom(server->getGalaxyName(), mainRoom);
	core3Room->setPrivate();
	mainRoom->addSubRoom(core3Room);

	groupRoom = createRoom("group", core3Room);
	groupRoom->setPrivate();
	core3Room->addSubRoom(groupRoom);

	guildRoom = createRoom("guild", core3Room);
	guildRoom->setPrivate();
	core3Room->addSubRoom(guildRoom);

	auctionRoom = createRoom("Auction", core3Room);
	core3Room->addSubRoom(auctionRoom);

	generalRoom = createRoom("General", core3Room);
	core3Room->addSubRoom(generalRoom);


}
开发者ID:Mesagoppinmypants,项目名称:mtgserver,代码行数:27,代码来源:ChatManagerImplementation.cpp

示例2: tokenizer

ChatRoom* ChatManagerImplementation::createRoomByFullPath(const String& path) {
	StringTokenizer tokenizer(path);
	tokenizer.setDelimeter(".");

	String game;
	tokenizer.getStringToken(game);

	ChatRoom* gameRoom = getGameRoom(game);

	if (gameRoom == NULL)
		return NULL;

	String channel;

	ChatRoom* room = gameRoom;
	while (tokenizer.hasMoreTokens()) {
		tokenizer.getStringToken(channel);

		if (room->getSubRoom(channel) == NULL)
			break;
		else
			room = room->getSubRoom(channel);
	}

	if (room == gameRoom)
		return NULL;

	if (room->isPrivate())
		return NULL;

	ChatRoom* newRoom = createRoom(channel, room);
	room->addSubRoom(newRoom);

	return newRoom;
}
开发者ID:Mesagoppinmypants,项目名称:mtgserver,代码行数:35,代码来源:ChatManagerImplementation.cpp

示例3: while

void *messenger( void *v ){
  ChatRoom *cr = reinterpret_cast<ChatRoom *>( v );

  while( cr )
    cr->distributeMessages();

  pthread_exit( NULL );
}
开发者ID:EricRobertBrewer,项目名称:SonomaState,代码行数:8,代码来源:server.cpp

示例4: ShowContextMenu

void ChatPanel::OnMouseEvent(OpWidget *widget, INT32 pos, INT32 x, INT32 y, MouseButton button, BOOL down, UINT8 nclicks)
{
	if (widget != m_rooms_view)
	{
		return;
	}

	if (!down && button == MOUSE_BUTTON_2)
	{
		ShowContextMenu(OpPoint(x+widget->GetRect().x,y+widget->GetRect().y),FALSE,FALSE);
		return;
	}

	OpTreeModelItem* item;

	item = m_rooms_view->GetItemByPosition(pos);

	if (item == NULL)
	{
		return;
	}

	BOOL click_state_ok = (IsSingleClick() && !down && nclicks == 1) || nclicks == 2;

	if (click_state_ok && button == MOUSE_BUTTON_1)
	{
		if (item->GetType() == OpTreeModelItem::CHATROOM_TYPE)
		{
			ChatRoom* chat_room = g_m2_engine->GetChatRoom(item->GetID());

			if (chat_room)
			{
				OpString room;
				chat_room->GetName(room);

				ChatInfo chat_info(room, OpStringC());

				g_application->GoToChat(chat_room->GetAccountID(),
					chat_info, TRUE);
			}
		}
		else if (item->GetType() == OpTreeModelItem::CHATTER_TYPE)
		{
			ChatRoom* chatter = g_m2_engine->GetChatter(item->GetID());
			if (chatter)
			{
				OpString chatter_name;
				chatter->GetName(chatter_name);

				ChatInfo chat_info(chatter_name, OpStringC());

				g_application->GoToChat(chatter->GetAccountID(),
					chat_info, FALSE);
			}
		}
	}
}
开发者ID:prestocore,项目名称:browser,代码行数:57,代码来源:ChatPanel.cpp

示例5: linphone_qt_init_chatroom

ChatRoom * linphone_qt_init_chatroom(LinphoneChatRoom *cr, const char *with){
	ChatRoom *chatw;
	QString tmp;
	chatw = new ChatRoom(w);
	tmp.sprintf("Chat with %s",with);
	chatw->setWindowTitle(tmp);
	chatw->setLinphoneChatRoom(cr);
	linphone_chat_room_set_user_data(cr,w);
	chatw->setAttribute(Qt::WA_DeleteOnClose);
	chatw->show();
	return chatw;
}
开发者ID:dormclub,项目名称:tjphone,代码行数:12,代码来源:chatroom.cpp

示例6: closeCurrent

void ChatRooms::closeCurrent() {
	ChatRoom* room = dynamic_cast<ChatRoom*>(currentWidget());
	if (room)
        museeq->leaveRoom(room->room());
    else {
        PublicChat* pchat = dynamic_cast<PublicChat*>(currentWidget());
        if (pchat) {
            museeq->stopPublicChat();
            delete pchat;
        }
    }
}
开发者ID:,项目名称:,代码行数:12,代码来源:

示例7: _locker

void ChatManagerImplementation::destroyRooms() {
	Locker _locker(_this.getReferenceUnsafeStaticCast());

	HashTableIterator<unsigned int, ManagedReference<ChatRoom* > > iter = roomMap->iterator();

	while (iter.hasNext()) {
		ChatRoom* room = iter.next();
		room->finalize();
	}

	roomMap->removeAll();

	gameRooms.removeAll();
}
开发者ID:Mesagoppinmypants,项目名称:mtgserver,代码行数:14,代码来源:ChatManagerImplementation.cpp

示例8: getGroupMember

void GroupObjectImplementation::disband() {
	// this locked
	ManagedReference<ChatRoom* > chat = chatRoom;

	for (int i = 0; i < groupMembers.size(); i++) {
		if (groupMembers.get(i) == NULL) {
			continue;
		}

		Reference<CreatureObject*> groupMember = getGroupMember(i).castTo<CreatureObject*>();

		try {
			Locker clocker(groupMember, _this.get());

			if (groupMember->isPlayerCreature()) {
				if (chat != NULL) {
					chat->removePlayer(groupMember, false);
					chat->sendDestroyTo(groupMember);

					ChatRoom* room = chat->getParent();
					room->sendDestroyTo(groupMember);
				}

				if (groupMember->getPlayerObject() != NULL) {
					PlayerObject* ghost = groupMember->getPlayerObject();
					ghost->removeWaypointBySpecialType(WaypointObject::SPECIALTYPE_NEARESTMISSIONFORGROUP);
				}
			}

			groupMember->updateGroup(NULL);
			//play->updateGroupId(0);

			//sendClosestWaypointDestroyTo(play);

			//removeSquadLeaderBonuses(play);
		} catch (Exception& e) {
			System::out << "Exception in GroupObject::disband(Player* player)\n";
		}
	}

	destroyChatRoom();

	if (hasSquadLeader())
		removeGroupModifiers();

	groupMembers.removeAll();

	//The mission waypoints should not be destroyed. They belong to the players.
	//missionWaypoints.removeAll();
}
开发者ID:Chilastra-Reborn,项目名称:Chilastra-source-code,代码行数:50,代码来源:GroupObjectImplementation.cpp

示例9: selected

void ChatRooms::selected(QWidget* chatwidget) {
	if (currentIndex() == 0)
		return;
	ChatRoom * uw = dynamic_cast<ChatRoom*>(chatwidget);
	if(uw && uw->highlighted() != 0) {
		uw->setHighlighted(0);
		setHighlight(uw->highlighted(), uw );
	}
	else if (!uw) {
        PublicChat * pc = dynamic_cast<PublicChat*>(chatwidget);
        if(pc && pc->highlighted() != 0) {
            pc->setHighlighted(0);
            setHighlight(pc->highlighted(), pc );
        }
	}
}
开发者ID:,项目名称:,代码行数:16,代码来源:

示例10: locker

void ChatManagerImplementation::initiatePlanetRooms() {
	// Planet Chat
	for (int i = 0; i < server->getZoneCount(); ++i) {
		ManagedReference<Zone*> zone = server->getZone(i);

		if (zone == NULL)
			continue;

		Locker locker(zone);

		ChatRoom* planetRoom = createRoom(zone->getZoneName(), core3Room);
		core3Room->addSubRoom(planetRoom);

		ChatRoom* planetaryChat = createRoom("Planet", planetRoom);
		planetRoom->addSubRoom(planetaryChat);
		zone->setChatRoom( planetaryChat );

	}
}
开发者ID:Mesagoppinmypants,项目名称:mtgserver,代码行数:19,代码来源:ChatManagerImplementation.cpp

示例11: setHighlight

void ChatRooms::setHighlight(int highlight, QWidget* chatwidget) {

	ChatRoom * uw = dynamic_cast<ChatRoom*>(chatwidget);
	PublicChat * pc = dynamic_cast<PublicChat*>(chatwidget);

    if (!uw && !pc)
        return;

	int pos;
	int tabHighlighted;
	if (uw) {
        pos = indexOf(uw);
        tabHighlighted = uw->highlighted();
	}
	else {
	    pos = indexOf(pc);
        tabHighlighted = pc->highlighted();
	}

	if(( currentIndex() != pos) && highlight > tabHighlighted )
	{
        if (uw)
            uw->setHighlighted(highlight);
        else
            pc->setHighlighted(highlight);

		if (highlight > 0)// Icon on tab
			tabBar()->setTabIcon(pos, QIcon(IMG("new-element")));
		if (highlight > 1)// Red tab
			tabBar()->setTabTextColor(pos, QColor(255, 0, 0));

	} else if (highlight == 0){
		tabBar()->setTabTextColor(pos, tabBar()->palette().buttonText().color());
		tabBar()->setTabIcon(pos, QIcon());
	}
}
开发者ID:,项目名称:,代码行数:36,代码来源:

示例12: clocker

void GroupManager::leaveGroup(ManagedReference<GroupObject*> group, CreatureObject* player) {
	// Pre: player locked
	// Post: player locked
	if (group == NULL)
		return;

	try {
		Locker clocker(group, player);

		ChatRoom* groupChannel = group->getGroupChannel();
		if (groupChannel != NULL && player->isPlayerCreature()) {
			CreatureObject* playerCreature = cast<CreatureObject*>( player);
			groupChannel->removePlayer(playerCreature, false);
			groupChannel->sendDestroyTo(playerCreature);

			ChatRoom* room = groupChannel->getParent();
			room->sendDestroyTo(playerCreature);
		}

		if (!group->isOtherMemberPlayingMusic(player))
			group->setBandSong("");

		player->updateGroup(NULL);

		//if (player != NULL && player->isOnline() && !player->isLoggingOut())
		if (player->isPlayerCreature())
			player->sendSystemMessage("@group:removed");

		player->unlock();

		group->removeMember(player);

		if (player->isPlayerCreature())
			group->sendDestroyTo(player);

		player->info("leaving group");

		if (group->getGroupSize() < 2) {
			group->disband();
		}

	} catch (Exception& e) {
		System::out << e.getMessage();
		e.printStackTrace();

	} catch (...) {
		player->wlock();

		throw;
	}

	player->wlock();
}
开发者ID:newtempest,项目名称:mtgserver,代码行数:53,代码来源:GroupManager.cpp

示例13: getTaggedName

void ChatManagerImplementation::handleChatRoomMessage(CreatureObject* sender, const UnicodeString& message, unsigned int roomID, unsigned int counter) {
	String name = sender->getFirstName();
	String fullName = "";

	if (sender->isPlayerCreature()) {
		ManagedReference<PlayerObject*> senderGhost = sender->getPlayerObject();

		if (senderGhost == NULL)
			return;

		if (senderGhost->isMuted()) {
			String reason = senderGhost->getMutedReason();

			if (reason != "")
				sender->sendSystemMessage("Your chat abilities are currently disabled by Customer Support for '" + reason + "'.");
			else
				sender->sendSystemMessage("Your chat abilities are currently disabled by Customer Support.");

			return;
		}

		fullName = getTaggedName(senderGhost, name);
	}

	ChatRoom* channel = getChatRoom(roomID);

	if (channel == NULL)
		return;

	if (!channel->hasPlayer(sender))
		return;

	Zone* zone = sender->getZone();
	if( zone == NULL ){
		return;
	}

	UnicodeString formattedMessage(formatMessage(message));

	ManagedReference<ChatRoom*> planetRoom = zone->getChatRoom();

	BaseMessage* msg = new ChatRoomMessage(fullName, formattedMessage, roomID);

	// Auction Chat, General Chat, and Planet Chat should adhere to player ignore list
	if( auctionRoom != NULL && auctionRoom->getRoomID() == roomID ) {
		channel->broadcastMessageCheckIgnore(msg, name);
	} else if (generalRoom != NULL && generalRoom->getRoomID() == roomID) {
		channel->broadcastMessageCheckIgnore(msg, name);
	} else if( planetRoom != NULL && planetRoom->getRoomID() == roomID ) {
		channel->broadcastMessageCheckIgnore(msg, name);
	} else {
		channel->broadcastMessage(msg);
	}

	BaseMessage* amsg = new ChatOnSendRoomMessage(counter);
	channel->broadcastMessage(amsg);

	/*Vector<Message*> messages;
	messages.add(msg);
	messages.add(amsg);

	channel->broadcastMessage(messages);*/
}
开发者ID:Mesagoppinmypants,项目名称:mtgserver,代码行数:63,代码来源:ChatManagerImplementation.cpp

示例14: switch

BOOL ChatPanel::OnInputAction(OpInputAction* action)
{
	INT32 account_id = 0;
	INT32 id = 0;
	OpString name;
	Type type = UNKNOWN_TYPE;
	BOOL is_room = FALSE;
	BOOL is_chatter = FALSE;
	BOOL is_account = FALSE;

	OpTreeModelItem* item = m_rooms_view->GetSelectedItem();

	if (item)
	{
		id = item->GetID();
		type = item->GetType();

		switch (type)
		{
			case CHATROOM_TYPE:
		{
				ChatRoom* chat_room = g_m2_engine->GetChatRoom(id);

			if (chat_room)
			{
					chat_room->GetName(name);
					account_id = chat_room->GetAccountID();
					is_room = TRUE;
			}
				break;
			}

			case CHATTER_TYPE:
			{
				ChatRoom* chatter = g_m2_engine->GetChatter(id);

				if (chatter)
				{
					chatter->GetName(name);
					account_id = chatter->GetAccountID();
					is_chatter = TRUE;
				}
				break;
		}

			case CHATROOM_SERVER_TYPE:
			{
				account_id = item->GetID();
				is_account = TRUE;
				break;
			}
		}
	}

	switch (action->GetAction())
	{
		case OpInputAction::ACTION_GET_ACTION_STATE:
		{
			OpInputAction* child_action = action->GetChildAction();

			switch (child_action->GetAction())
			{
				case OpInputAction::ACTION_JOIN_CHAT_ROOM:
				{
					if (action->GetActionDataString())
						return FALSE;

					child_action->SetEnabled(is_room);
					return TRUE;
				}

				case OpInputAction::ACTION_LEAVE_CHAT_ROOM:
				{
					if (action->GetActionDataString())
						return FALSE;

					child_action->SetEnabled(is_room && ChatDesktopWindow::FindChatRoom(account_id, name, TRUE));
					return TRUE;
				}

				case OpInputAction::ACTION_SET_CHAT_STATUS:
				{
					if (child_action->GetActionData())
						return FALSE;

					AccountTypes::ChatStatus action_chat_status = g_application->GetChatStatusFromString(child_action->GetActionDataString());

					BOOL is_connecting = FALSE;
					AccountTypes::ChatStatus chat_status = g_application->GetChatStatus(account_id, is_connecting);

					child_action->SetSelected(chat_status == action_chat_status);

					if (is_connecting)
						child_action->SetEnabled(action_chat_status == AccountTypes::OFFLINE);
					else
						child_action->SetEnabled(g_application->SetChatStatus(account_id, chat_status, TRUE));

					return TRUE;
				}
				case OpInputAction::ACTION_DELETE:
//.........这里部分代码省略.........
开发者ID:prestocore,项目名称:browser,代码行数:101,代码来源:ChatPanel.cpp

示例15: pthread_mutex_unlock

void *commandThread( void *sID ){
  int sockID = *( reinterpret_cast<int *>( sID ) );
  pthread_mutex_unlock( &accept_mutex );

  int name_ok, n, cmdsize = COMMAND_LEN, cmdstatus, wbsize;
  bool valid, write_back;
  string clientName, comstr, comhead = "", comarg = "", wbmessage;
  char username[ CLIENT_NAME_LEN + 1 ];
  char buff[ MAXLINE ];
  Client *client;

  cout << "cThread(" << pthread_self() << "): Reading username...\n";
  if( ( readN( sockID, username, CLIENT_NAME_LEN ) ) < 0 ){
    cout << "cThread(" << pthread_self() << "): Read error.\n";
    exit( 6 );
  }

  clientName = username;
  if( allClients.exists( clientName ) ){
    name_ok = NAME_NOT_AVAILABLE;
    name_ok = htons( name_ok );
    if( ( writeN( sockID, ( char * ) &name_ok, sizeof( name_ok ) ) ) < 0 ){
      cout << "cThread(" << pthread_self() << "): Write error.\n";
      exit( 7 );
    }
    pthread_exit( NULL );
  }
  
  name_ok = NAME_AVAILABLE;
  name_ok = htons( name_ok );
  if( ( writeN( sockID, ( char * ) &name_ok, sizeof( name_ok ) ) ) < 0 ){
    cout << "cThread(" << pthread_self() << "): Write error.\n";
    exit( 8 );
  }

  client = new Client( clientName, defaultChatRoom );
  defaultChatRoom->addClient( client );
  client->setCommandSockDesc( sockID );
  allClients.addClient( client );

  while( !client->isActive() );
 
  memset( buff, '\0', MAXLINE );

  // first, read the size of the command
  while( ( readN( sockID, ( char * ) &cmdsize, sizeof( cmdsize ) ) ) > 0 ){

    // then, read the command
    if( ( n = readN( sockID, buff, cmdsize ) ) < 0 ){
      cout << "cThread(" << pthread_self() << "): Read error.\n";
      exit( 9 );
    }
    comstr = buff;
    cout << "cThread(" << pthread_self() << "): " << comstr << "\n";
    
    // In order to keep the internals consistent across clients, we lock this region
    pthread_mutex_lock( &command_mutex );

    // first pass - see if the command has the right number of characters
    valid = true;
    write_back = false;
    if( comstr.length() > 3 ){
      for( int i = 0; i < 4; i++ )
	comhead += comstr[i];
    }
    else
      valid = false;
    if( comhead != "bye." && comhead != "shut" && comhead != "lscr" && comhead != "lssu" && comhead != "myde" )
      if( comstr.length() > 5 )
	for( int j = 5; j < comstr.length(); j++ )
	  comarg += comstr[j];
      else
	valid = false;
    
    // second pass - interpret the command
    if( valid ){
      
      // "bye." - client wishes to exit the server
      if( comhead == "bye." ){
	allChatRooms.wipeClient( client->getID() );
	allClients.deleteClient( client->getID() );
	client->closeReader();
	client->closeWriter();
      }
      // "crea" - CREAte a new chatroom
      else if( comhead == "crea" ){
	ChatRoom *newRoom = new ChatRoom( comarg );
	if( !allChatRooms.addChatRoom( newRoom ) )
	  valid = false;
	else
	  dispatch( newRoom );
      }
      // "subs" - SUBScribe to an existing chatroom
      else if( comhead == "subs" ){
	ChatRoom *newRoom;
	if( newRoom = allChatRooms.exists( comarg ) )
	  if( !newRoom->addClient( client ) )
	    valid = false;
	  else;
	else
//.........这里部分代码省略.........
开发者ID:EricRobertBrewer,项目名称:SonomaState,代码行数:101,代码来源:server.cpp


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