Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/network/Host.h @ 6766

Last change on this file since 6766 was 6073, checked in by rgrieder, 15 years ago

Found more tabs in the trunk.

  • Property svn:eol-style set to native
File size: 3.0 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 *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#ifndef _NETWORK_Host_H__
30#define _NETWORK_Host_H__
31
32#include "NetworkPrereqs.h"
33#include "core/CorePrereqs.h"
34
35namespace orxonox {
36
37  const unsigned int CLIENTID_SERVER = 0;
38  const unsigned int NETWORK_FREQUENCY = 30;
39  const float NETWORK_PERIOD = 1.0f/NETWORK_FREQUENCY;
40
41/**
42*       @brief Base class of Server and Client
43*       This is the Base class of the Server and Client classes
44*       - Makes server and client a singleton
45*       - defines static functions available on both server and client
46*       - is the interface to be used when communicating with the network
47*       @author Oliver Scheuss
48*/
49class _NetworkExport Host{
50  private:
51    //TODO add theese functions or adequate
52    //virtual bool processChat(packet::Chat *message, unsigned int clientID)=0;
53    //virtual bool sendChat(packet::Chat *chat)=0;
54    virtual bool queuePacket(ENetPacket *packet, int clientID)=0;
55    virtual bool chat(const std::string& message)=0;
56    virtual bool broadcast(const std::string& message)=0;
57    virtual bool processChat(const std::string& message, unsigned int playerID)=0;
58    virtual bool isServer_()=0;
59
60
61
62  protected:
63    Host();
64    virtual ~Host();
65    static Host *instance_;
66    unsigned int clientID_;
67    unsigned int shipID_;
68
69  public:
70    static bool running(){return instance_!=0;}
71    static bool addPacket(ENetPacket *packet, int clientID=0);
72    //static bool chat(std::string& message);
73//     static bool receiveChat(packet::Chat *message, unsigned int clientID);
74    static unsigned int getPlayerID();
75    static unsigned int getShipID(){return instance_->shipID_;}
76    static void setClientID(unsigned int id){ instance_->clientID_ = id; }
77    static void setShipID(unsigned int id){ instance_->shipID_ = id; }
78    static bool isServer(){ return instance_->isServer_(); }
79    static bool Chat(const std::string& message);
80    static bool Broadcast(const std::string& message);
81    static bool incomingChat(const std::string& message, unsigned int playerID);
82    virtual void printRTT()=0;
83  private:
84    ConsoleCommand* printRTTCC_;
85};
86
87}
88
89#endif /* _NETWORK_Host_H__ */
Note: See TracBrowser for help on using the repository browser.