[7161] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
[7630] | 23 | * Fabian 'x3n' Landau (original) |
---|
[7161] | 24 | * Co-authors: |
---|
[7630] | 25 | * Sandro 'smerkli' Merkli (copied and adapted to WAN) |
---|
[7161] | 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
[7630] | 29 | #ifndef WANDISCOVERY_H |
---|
| 30 | #define WANDISCOVERY_H |
---|
[7161] | 31 | |
---|
| 32 | #include "NetworkPrereqs.h" |
---|
| 33 | #include "packet/ServerInformation.h" |
---|
| 34 | #include "util/Singleton.h" |
---|
[7631] | 35 | #include "MasterServerComm.h" |
---|
[7650] | 36 | #include "MasterServerProtocol.h" |
---|
[7161] | 37 | |
---|
| 38 | #include <vector> |
---|
| 39 | |
---|
[7692] | 40 | #define WANDISC_MAXTRIES 5 |
---|
[7631] | 41 | |
---|
[7161] | 42 | // tolua_begin |
---|
| 43 | namespace orxonox |
---|
| 44 | { |
---|
| 45 | |
---|
[7630] | 46 | class _NetworkExport WANDiscovery |
---|
[7161] | 47 | // tolua_end |
---|
[7630] | 48 | : public Singleton<WANDiscovery> |
---|
[7161] | 49 | { // tolua_export |
---|
[7630] | 50 | friend class Singleton<WANDiscovery>; |
---|
[7161] | 51 | public: |
---|
[7631] | 52 | /** constructor */ |
---|
[7630] | 53 | WANDiscovery(); |
---|
[7631] | 54 | |
---|
| 55 | /** destructor */ |
---|
[7630] | 56 | ~WANDiscovery(); |
---|
[7631] | 57 | |
---|
| 58 | /** ask server for server list */ |
---|
[7161] | 59 | void discover(); // tolua_export |
---|
[7631] | 60 | |
---|
| 61 | /** \param index Index to get the name of |
---|
| 62 | * \return The name of the server |
---|
| 63 | * |
---|
| 64 | * Get the name of the server at index index. |
---|
| 65 | */ |
---|
[7161] | 66 | std::string getServerListItemName( unsigned int index ); // tolua_export |
---|
[7631] | 67 | |
---|
| 68 | /** \param index Index to get the IP of |
---|
| 69 | * \return The IP of the server |
---|
| 70 | * |
---|
| 71 | * Get the IP of the server at index index. |
---|
| 72 | */ |
---|
[7161] | 73 | std::string getServerListItemIP( unsigned int index ); // tolua_export |
---|
[7631] | 74 | |
---|
| 75 | /** \return an instance of WANDiscovery |
---|
| 76 | * |
---|
| 77 | * Create and return an instance of WANDiscovery. |
---|
| 78 | */ |
---|
| 79 | static WANDiscovery& getInstance() { return Singleton<WANDiscovery>::getInstance(); } // tolua_export |
---|
[7651] | 80 | |
---|
[7672] | 81 | /* todo: might make this private and use getter/setter methods |
---|
| 82 | * at some later time. |
---|
| 83 | */ |
---|
[7657] | 84 | /** game server list */ |
---|
| 85 | std::vector<packet::ServerInformation> servers_; |
---|
[7161] | 86 | |
---|
| 87 | private: |
---|
[7631] | 88 | /** Singleton pointer */ |
---|
[7630] | 89 | static WANDiscovery* singletonPtr_s; |
---|
[7631] | 90 | |
---|
| 91 | /** Master server communications object */ |
---|
| 92 | MasterServerComm msc; |
---|
| 93 | |
---|
[7161] | 94 | }; // tolua_export |
---|
| 95 | |
---|
| 96 | } // tolua_export |
---|
| 97 | |
---|
[7630] | 98 | #endif // WANDISCOVERY_H |
---|