Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/masterserver/src/libraries/network/MasterServerComm.h @ 7631

Last change on this file since 7631 was 7631, checked in by smerkli, 14 years ago

added comments, lua function (to be tested) and various implementation bits

File size: 2.4 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#include <cstdlib>
30#include <cstdio>
31#include <cstring>
32#include <enet/enet.h>
33
34namespace orxonox
35{
36  class MasterServerComm
37  {
38    public: 
39      /** constructor */
40      MasterServerComm();
41
42      /** destructor */
43      ~MasterServerComm();
44
45      /** \return 0 for success, other for error
46       *
47       * Initialize everything for the master server communication
48       */
49      int initialize();
50
51
52      /** \param address Address to connect to (Host name or IP in text form)
53       * \param port Port to connect on
54       * \return 0 for success, other for error
55       *
56       * Connect to the master server with the given address on the given port.
57       */
58      int connect( char *address, unsigned int port );
59
60      /** \param data The data to be sent.
61       * \return 0 for success, other for error.
62       *
63       * Send a request to the master server containing data specified in data
64       */
65      int sendRequest( char *data );
66
67      /** \param callback The callback function to call with data receivced.
68       * \return 0 for success, other for error
69       *
70       * Poll the master server for new data and act accordingly */
71      int pollForReply( int (*callback)( char*, ENetEvent* ) );
72
73    private:
74      /** client handle */
75      ENetHost *client;
76
77      /** event data holder */
78      ENetEvent event;
79
80      /** address holder */
81      ENetAddress address;
82
83      /** peer data holder */
84      ENetPeer *peer;
85  };
86
87}
Note: See TracBrowser for help on using the repository browser.