chat code

This commit is contained in:
Max-Wilhelm Bruker 2009-08-23 03:43:09 +02:00
parent 120193fb0b
commit e6a419aa3d
9 changed files with 51 additions and 9 deletions

View file

@ -39,6 +39,9 @@ Server::Server(QObject *parent)
chatChannelList << new ChatChannel("channel1", "testchannel 1");
chatChannelList << new ChatChannel("channel2", "testchannel 2");
for (int i = 0; i < chatChannelList.size(); ++i)
connect(chatChannelList[i], SIGNAL(channelInfoChanged()), this, SLOT(broadcastChannelUpdate()));
}
Server::~Server()
@ -163,6 +166,14 @@ void Server::broadcastGameListUpdate(ServerGame *game)
players[i]->msg(line);
}
void Server::broadcastChannelUpdate()
{
QString line = qobject_cast<ChatChannel *>(sender())->getChannelListLine();
for (int i = 0; i < players.size(); ++i)
if (players[i]->getAcceptsChatChannelListChanges())
players[i]->msg(line);
}
void Server::addClientToGame(int gameId, ServerSocket *client)
{
ServerGame *game = getGame(gameId);