Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pch/src/network/Host.h @ 3163

Last change on this file since 3163 was 3150, checked in by rgrieder, 15 years ago

Build fixes (X11 defines the None macro…)

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