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