Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/resource/src/network/Host.h @ 5706

Last change on this file since 5706 was 3214, checked in by scheusso, 15 years ago

merged netp5 back to trunk

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