Esempio n. 1
0
void Server::addRoom(Server_Room *newRoom)
{
    QWriteLocker locker(&roomsLock);
    qDebug() << "Adding room: ID=" << newRoom->getId() << "name=" << newRoom->getName();
    rooms.insert(newRoom->getId(), newRoom);
    connect(newRoom, SIGNAL(roomInfoChanged(ServerInfo_Room)), this, SLOT(broadcastRoomUpdate(const ServerInfo_Room &)), Qt::QueuedConnection);
}
Esempio n. 2
0
void Server_Room::removeGame()
{
	Server_Game *game = static_cast<Server_Game *>(sender());
	broadcastGameListUpdate(game);
	games.remove(game->getGameId());
	
	emit gameClosing(game->getGameId());
	emit roomInfoChanged();
}
Esempio n. 3
0
void Server_Room::addClient(Server_ProtocolHandler *client)
{
	sendRoomEvent(new Event_JoinRoom(id, new ServerInfo_User(client->getUserInfo())));
	append(client);
	
	QList<ServerInfo_User *> eventUserList;
	for (int i = 0; i < size(); ++i)
		eventUserList.append(new ServerInfo_User(at(i)->getUserInfo()));

	emit roomInfoChanged();
}
Esempio n. 4
0
Server_Game *Server_Room::createGame(const QString &description, const QString &password, int maxPlayers, bool spectatorsAllowed, bool spectatorsNeedPassword, bool spectatorsCanTalk, bool spectatorsSeeEverything, Server_ProtocolHandler *creator)
{
	Server_Game *newGame = new Server_Game(creator, static_cast<Server *>(parent())->getNextGameId(), description, password, maxPlayers, spectatorsAllowed, spectatorsNeedPassword, spectatorsCanTalk, spectatorsSeeEverything, this);
	games.insert(newGame->getGameId(), newGame);
	connect(newGame, SIGNAL(gameClosing()), this, SLOT(removeGame()));
	
	broadcastGameListUpdate(newGame);
	
	emit gameCreated(newGame);
	emit roomInfoChanged();
	
	return newGame;
}
Esempio n. 5
0
void Server_Room::removeClient(Server_ProtocolHandler *client)
{
	removeAt(indexOf(client));
	sendRoomEvent(new Event_LeaveRoom(id, client->getUserInfo()->getName()));
	emit roomInfoChanged();
}