Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 5678 was 3214, checked in by scheusso, 16 years ago

merged netp5 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
[3214]29#ifndef _NETWORK_Host_H__
30#define _NETWORK_Host_H__
[1666]31
[1705]32#include "NetworkPrereqs.h"
[1666]33
[2171]34namespace orxonox {
[1666]35
[3196]36  const unsigned int CLIENTID_SERVER = 0;
[3084]37  const unsigned int NETWORK_FREQUENCY = 30;
38  const float NETWORK_PERIOD = 1.0f/NETWORK_FREQUENCY;
39
[1666]40/**
[1907]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
[1666]47*/
[2087]48class _NetworkExport Host{
[1666]49  private:
50    //TODO add theese functions or adequate
[1711]51    //virtual bool processChat(packet::Chat *message, unsigned int clientID)=0;
52    //virtual bool sendChat(packet::Chat *chat)=0;
[1666]53    virtual bool queuePacket(ENetPacket *packet, int clientID)=0;
[2087]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;
[1907]57    virtual bool isServer_()=0;
[1740]58
59
60
[1666]61  protected:
62    Host();
[1740]63    virtual ~Host();
[1705]64    static Host *instance_;
[1907]65    unsigned int clientID_;
66    unsigned int shipID_;
[1740]67
[1666]68  public:
69    static bool running(){return instance_!=0;}
70    static bool addPacket(ENetPacket *packet, int clientID=0);
[1711]71    //static bool chat(std::string& message);
72//     static bool receiveChat(packet::Chat *message, unsigned int clientID);
[1907]73    static unsigned int getPlayerID();
[1732]74    static unsigned int getShipID(){return instance_->shipID_;}
[1711]75    static void setClientID(unsigned int id){ instance_->clientID_ = id; }
76    static void setShipID(unsigned int id){ instance_->shipID_ = id; }
[2087]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);
[1711]81  private:
[1666]82};
83
84}
85
[3214]86#endif /* _NETWORK_Host_H__ */
Note: See TracBrowser for help on using the repository browser.