diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-10-11 14:40:58 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-10-11 14:40:58 +0000 |
| commit | 927c42e73cce66acccc7056ea330a2362b455a00 (patch) | |
| tree | fd37832bb336c19c2dc5d6776c36e6fff0b969d0 /signet/Server.cpp | |
| parent | 3a096bed018254f9d662f9ae85792b8ae5df4837 (diff) | |
| download | sigen-927c42e73cce66acccc7056ea330a2362b455a00.tar.gz sigen-927c42e73cce66acccc7056ea330a2362b455a00.tar.xz sigen-927c42e73cce66acccc7056ea330a2362b455a00.zip | |
[FIX] Reordered sections in class declarations
[FIX] Using QSet rather than QList for players
[ADD] Started signet library (compilation fails)
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@273 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'signet/Server.cpp')
| -rw-r--r-- | signet/Server.cpp | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/signet/Server.cpp b/signet/Server.cpp new file mode 100644 index 00000000..7c7b44d5 --- /dev/null +++ b/signet/Server.cpp @@ -0,0 +1,90 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "Server.h" + +// Signet includes +#include "Room.h" +#include "ServerConnectionHandler.h" + +// KDE includes +#include <KConfig> +#include <KGlobal> + +// Qt includes +#include <QtNetwork/QHostAddress> +#include <QtNetwork/QTcpSocket> + +Signet::Server::Server(QObject* parent) : + QObject(parent) +{ + m_handler->connectToMaster(KGlobal::config()->group("Master Server")); +// QHostAddress masterAddress; +// int port; +// QString key; +// int timeout; +// if (config->hasGroup("Master Server")) +// { +// const KConfigGroup& group = config->group("Master Server"); +// QString address = group.readEntry("Address", ""); +// if (!masterAddress.setAddress(address)) +// qFatal(QString("Invalid address for the master server: %1").arg(address)); +// port = group.readEntry("Port", -1); +// if (port < 0) +// qFatal(QString("Invalid port for the master server: %1").arg(port)); +// key = group.readEntry("Key", ""); +// timeout = group.readEntry("Timeout", 30000); +// } +// else +// { +// // TODO: Configuration not complete +// } +// // TODO: Proxy support? +// m_masterServer->connectToHost(masterAddress, port); +// if (!m_masterServer->waitForConnect(timeout)) +// { +// // TODO: Connect failed +// } +} + +void Signet::Server::createRoom(const QString& room) +{ + if (m_rooms.contains(room)) + return; + m_rooms[room] = new Room(room, this); +} + +void Signet::Server::closeRoom(const QString& room) +{ + if (m_rooms.contains(room)) + { + delete m_rooms[room]; + m_rooms.remove(room); + } +} + +bool Signet::Server::joinRoom(Client* client, const QString& roomName) +{ + if (!m_rooms.contains(roomName)) + createRoom(roomName); + m_rooms[room]->addClient(client); +} + +void Signet::Server::receiveData(const QByteArray& data) +{ +} |
