Doomseeker
   
  • Doomseeker
  • Wadseeker
  • Download
  • Tracker
  • Git
  • Docs
  • Main Page
  • Classes
  • Files
  • File List
  • File Members

src/core/masterserver/masterclient.h

00001 //------------------------------------------------------------------------------
00002 // masterclient.h
00003 //------------------------------------------------------------------------------
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00018 // 02110-1301, USA.
00019 //
00020 //------------------------------------------------------------------------------
00021 // Copyright (C) 2009 "Blzut3" <admin@maniacsvault.net>
00022 //------------------------------------------------------------------------------
00023 
00024 #ifndef __MASTERSERVER_H__
00025 #define __MASTERSERVER_H__
00026 
00027 #include <QObject>
00028 #include <QHostAddress>
00029 #include <QList>
00030 
00031 #include "global.h"
00032 
00033 class Message;
00034 class EnginePlugin;
00035 class Server;
00036 class QFile;
00037 class QUdpSocket;
00038 
00043 class MAIN_EXPORT MasterClient : public QObject
00044 {
00045         Q_OBJECT
00046 
00047         public:
00061                 static QUdpSocket*              pGlobalUdpSocket;
00062 
00063                 MasterClient();
00064                 virtual ~MasterClient();
00065 
00066                 bool                                    hasServer(const Server*);
00067 
00072                 bool                                    isAddressDataCorrect(const QHostAddress& address, unsigned short port)
00073                 {
00074                         return (this->address == address && this->port == port);
00075                 }
00076 
00082                 bool                                    isEnabled() const { return enabled; }
00083                 bool                                    isTimeouted() const { return bTimeouted; }
00084                 int                                             numPlayers() const;
00085                 int                                             numServers() const { return servers.size(); }
00086                 Server                                  *operator[] (int index) const { return servers[index]; }
00087 
00095                 virtual const EnginePlugin*             plugin() const = 0;
00096 
00097                 void                                    pushPacketToCache(QByteArray &data);
00098                 void                                    resetPacketCaching();
00099 
00107                 virtual bool                    readMasterResponse(QByteArray &data)=0;
00108 
00115                 virtual bool                    readMasterResponse(QHostAddress& address, unsigned short port, QByteArray &data);
00116 
00117                 QList<Server*>                  &serverList() { return servers; }
00118                 const QList<Server*>    &serverList() const { return servers; }
00119 
00120                 void                                    updateAddress();
00121 
00122         public slots:
00128                 virtual void                    refresh();
00129 
00133                 void                                    setEnabled(bool b) { enabled = b; }
00134 
00140                 void                                    timeoutRefresh();
00141 
00142         signals:
00143                 void                                    listUpdated();
00144 
00149                 void                                    message(const QString& title, const QString& content, bool isError);
00150 
00161                 void                    messageImportant(const Message& message);
00162 
00172                 void                                    newServerBatchReceived(const QList<Server* >& servers);
00173 
00174         protected:
00175                 QHostAddress                    address;
00176 
00184                 bool                                    bTimeouted;
00185                 bool                                    enabled;
00186                 unsigned short                  port;
00187                 QList<Server *>                 servers;
00188 
00189                 QFile                                   *cache;
00190 
00194                 void                                    emptyServerList();
00195 
00201                 QString                 engineName() const;
00202 
00210                 virtual bool                    getServerListRequest(QByteArray &data)=0;
00211 
00216                 void                                    notifyBanned();
00221                 void                                    notifyDelay();
00222                 
00227                 void notifyError();
00228 
00233                 void                                    notifyUpdate();
00234 
00235                 bool                                    preparePacketCache(bool write);
00236                 void                                    readPacketCache();
00237 
00241                 virtual void                    timeoutRefreshEx() {}
00242 };
00243 
00244 #endif /* __MASTERSERVER_H__ */
   
Doomseeker © 2009-2024 The Doomseeker Team