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: |
---|
23 | * Fabian 'x3n' Landau (original) |
---|
24 | * Co-authors: |
---|
25 | * Sandro 'smerkli' Merkli (copied and adapted to WAN) |
---|
26 | * |
---|
27 | */ |
---|
28 | |
---|
29 | #ifndef WANDISCOVERY_H |
---|
30 | #define WANDISCOVERY_H |
---|
31 | |
---|
32 | #include "NetworkPrereqs.h" |
---|
33 | #include "packet/ServerInformation.h" |
---|
34 | #include "core/ConfigFileManager.h" |
---|
35 | #include "util/Singleton.h" |
---|
36 | #include "core/OrxonoxClass.h" |
---|
37 | #include "core/ConfigValueIncludes.h" |
---|
38 | #include "core/CoreIncludes.h" |
---|
39 | #include "MasterServerComm.h" |
---|
40 | #include "MasterServerProtocol.h" |
---|
41 | |
---|
42 | #include <vector> |
---|
43 | |
---|
44 | #define WANDISC_MAXTRIES 5 |
---|
45 | |
---|
46 | // tolua_begin |
---|
47 | namespace orxonox |
---|
48 | { |
---|
49 | |
---|
50 | class _NetworkExport WANDiscovery |
---|
51 | // tolua_end |
---|
52 | : public Singleton<WANDiscovery>, public OrxonoxClass |
---|
53 | { // tolua_export |
---|
54 | friend class Singleton<WANDiscovery>; |
---|
55 | public: |
---|
56 | /** constructor */ |
---|
57 | WANDiscovery(); |
---|
58 | |
---|
59 | /** destructor */ |
---|
60 | ~WANDiscovery(); |
---|
61 | |
---|
62 | /** ask server for server list */ |
---|
63 | void discover(); // tolua_export |
---|
64 | |
---|
65 | /** \param index Index to get the name of |
---|
66 | * \return The name of the server |
---|
67 | * |
---|
68 | * Get the name of the server at index index. |
---|
69 | */ |
---|
70 | std::string getServerListItemName( unsigned int index ); // tolua_export |
---|
71 | |
---|
72 | /** \param index Index to get the IP of |
---|
73 | * \return The IP of the server |
---|
74 | * |
---|
75 | * Get the IP of the server at index index. |
---|
76 | */ |
---|
77 | std::string getServerListItemIP( unsigned int index ); // tolua_export |
---|
78 | |
---|
79 | /** \return an instance of WANDiscovery |
---|
80 | * |
---|
81 | * Create and return an instance of WANDiscovery. |
---|
82 | */ |
---|
83 | static WANDiscovery& getInstance() { return Singleton<WANDiscovery>::getInstance(); } // tolua_export |
---|
84 | |
---|
85 | /* todo: might make this private and use getter/setter methods |
---|
86 | * at some later time. |
---|
87 | */ |
---|
88 | /** game server list */ |
---|
89 | std::vector<packet::ServerInformation> servers_; |
---|
90 | |
---|
91 | /** Function used for the configuration file parameter update */ |
---|
92 | void setConfigValues(); |
---|
93 | |
---|
94 | private: |
---|
95 | /** Singleton pointer */ |
---|
96 | static WANDiscovery* singletonPtr_s; |
---|
97 | |
---|
98 | /** Master server communications object */ |
---|
99 | MasterServerComm msc; |
---|
100 | |
---|
101 | /** master server address */ |
---|
102 | std::string msaddr; |
---|
103 | |
---|
104 | }; // tolua_export |
---|
105 | |
---|
106 | } // tolua_export |
---|
107 | |
---|
108 | #endif // WANDISCOVERY_H |
---|