Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentation2/src/libraries/network/MasterServerComm.h @ 7793

Last change on this file since 7793 was 7793, checked in by scheusso, 14 years ago

some changes in WANDiscovering:

  • fixed a bug which caused memory corruptions (was caused by double frees)
  • separated WANDiscovery into WANDiscoverable and WANDiscovery in order to prevent crashes when destructing GSServer and Closing the Server connection
File size: 2.9 KB
Line 
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 *      Sandro 'smerkli' Merkli
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#ifndef _MasterServerComm_H__
30#define _MasterServerComm_H__
31
32#include <cstdlib>
33#include <cstdio>
34#include <string>
35#include <cstring>
36#include <enet/enet.h>
37
38
39namespace orxonox
40{
41  class MasterServerComm
42  { 
43    public: 
44      /** constructor */
45      MasterServerComm();
46
47      /** destructor */
48      ~MasterServerComm();
49
50      /** \return 0 for success, other for error
51       *
52       * Initialize everything for the master server communication
53       */
54      int initialize();
55     
56      void update();
57
58
59      /** \param address Address to connect to (Host name or IP in text form)
60       * \param port Port to connect on
61       * \return 0 for success, other for error
62       *
63       * Connect to the master server with the given address on the given port.
64       */
65      int connect( const char *address, unsigned int port );
66
67      /** \return 0 for success, other for error
68       *
69       * Disconnect from master server.
70       */
71      int disconnect( void );
72
73      /** \param data The data to be sent.
74       * \return 0 for success, other for error.
75       *
76       * Send a request to the master server containing data specified in data
77       */
78      int sendRequest( const char *data );
79
80      /** \param data The data to be sent.
81       * \return 0 for success, other for error.
82       *
83       * Send a request to the master server containing data specified in data
84       * (string version)
85       */
86      int sendRequest( std::string data );
87
88      /** \param callback The callback function to call with data receivced.
89       * \return 0 for success, other for error
90       *
91       * Poll the master server for new data and act accordingly */
92      int pollForReply( int (*callback)( char*, ENetEvent* ), int delayms );
93
94    private:
95      /** client handle */
96      ENetHost* client;
97
98      /** event data holder */
99      ENetEvent event;
100
101      /** address holder */
102      ENetAddress address;
103
104      /** peer data holder */
105      ENetPeer* peer;
106  }; 
107
108} 
109
110#endif /* _MasterServerComm_H__ */
Note: See TracBrowser for help on using the repository browser.