Пример #1
0
void NotificationDialog::slotOk()
{
	TQListBoxItem *item = m_view->actionsList->selectedItem();

	if ( item != 0L )
	{
		ActionListBoxItem *action_item
			= static_cast<ActionListBoxItem*>( item );
		NotifierAction *action = action_item->action();

		launchAction( action );
	}
}
Пример #2
0
void GameManager::run()
{
    while (1)
    {
        auto action = _serv->getActions();
        if (action)
        {
            checkDeadClients();
            launchAction(*action);
        }
            auto it = _rooms.begin();
        while (it != _rooms.end())
        {
            if ((*it)->getNbPlayer() == (*it)->getMaxPlayer())
            {
                auto players = (*it)->getPlayers();
                std::string playerNames("");
                Packet packetRdy = Packet::build(READY, "");
                playerNames.append(players[0]->getName());
                playerNames += " ";
                for (unsigned int i=1; i<players.size(); ++i)
                {
                    reinterpret_cast<ASocket *>(players[i])->addData<Packet>(packetRdy, serPacket);
                    playerNames.append(players[i]->getName());
                    playerNames += " ";
                }
                Packet packet = Packet::build(DATAMAP, playerNames);
                reinterpret_cast<ASocket *>(players[0])->addData<Packet>(packet, serPacket);
                ++it;
            }
            else if ((*it)->getNbPlayer() == 0)
            {
                int port =(*it)->getPort();
                std::string roomName = (*it)->getName();
                it = removeRoom((*it)->getName());
                _pool.releaseThread(roomName);
                _ports[port] = false;
            }
            else
                ++it;
        }
        _serv->getCond()->wait();
    }
}