Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/network/Host.h @ 3133

Last change on this file since 3133 was 3084, checked in by landauf, 15 years ago

merged netp3 branch back to trunk

  • Property svn:eol-style set to native
File size: 2.9 KB
RevLine 
[1666]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
[1705]33#include "NetworkPrereqs.h"
[1666]34#include "packet/Chat.h"
35
[2171]36namespace orxonox {
[1666]37
[3084]38  const int CLIENTID_SERVER = 0;
39  const unsigned int NETWORK_FREQUENCY = 30;
40  const float NETWORK_PERIOD = 1.0f/NETWORK_FREQUENCY;
41
[1666]42/**
[1907]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
[1666]49*/
[2087]50class _NetworkExport Host{
[1666]51  private:
52    //TODO add theese functions or adequate
[1711]53    //virtual bool processChat(packet::Chat *message, unsigned int clientID)=0;
54    //virtual bool sendChat(packet::Chat *chat)=0;
[1666]55    virtual bool queuePacket(ENetPacket *packet, int clientID)=0;
[2087]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;
[1907]59    virtual bool isServer_()=0;
[1740]60
61
62
[1666]63  protected:
64    Host();
[1740]65    virtual ~Host();
[1705]66    static Host *instance_;
[1907]67    unsigned int clientID_;
68    unsigned int shipID_;
[1740]69
[1666]70  public:
71    static bool running(){return instance_!=0;}
72    static bool addPacket(ENetPacket *packet, int clientID=0);
[1711]73    //static bool chat(std::string& message);
74//     static bool receiveChat(packet::Chat *message, unsigned int clientID);
[1907]75    static unsigned int getPlayerID();
[1732]76    static unsigned int getShipID(){return instance_->shipID_;}
[1711]77    static void setClientID(unsigned int id){ instance_->clientID_ = id; }
78    static void setShipID(unsigned int id){ instance_->shipID_ = id; }
[2087]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);
[1711]83  private:
[1666]84};
85
86}
87
88#endif
Note: See TracBrowser for help on using the repository browser.