[3201] | 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 |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | // |
---|
| 30 | // C++ Interface: Connection |
---|
| 31 | // |
---|
| 32 | // Description: |
---|
| 33 | // |
---|
| 34 | // |
---|
| 35 | // Author: Oliver Scheuss, (C) 2007 |
---|
| 36 | // |
---|
| 37 | // Copyright: See COPYING file that comes with this distribution |
---|
| 38 | // |
---|
| 39 | // |
---|
| 40 | #ifndef _Connection_H__ |
---|
| 41 | #define _Connection_H__ |
---|
| 42 | |
---|
| 43 | #include "NetworkPrereqs.h" |
---|
| 44 | |
---|
| 45 | namespace orxonox |
---|
| 46 | { |
---|
[3203] | 47 | const unsigned int NETWORK_PORT = 55556; |
---|
| 48 | const unsigned int NETWORK_MAX_CONNECTIONS = 50; |
---|
| 49 | const unsigned int NETWORK_WAIT_TIMEOUT = 0; |
---|
| 50 | const unsigned int NETWORK_DEFAULT_CHANNEL = 0; |
---|
| 51 | const unsigned int NETWORK_MAX_QUEUE_PROCESS_TIME = 5; |
---|
[3201] | 52 | |
---|
| 53 | class _NetworkExport Connection{ |
---|
| 54 | public: |
---|
[3209] | 55 | virtual ~Connection(); |
---|
[3201] | 56 | |
---|
| 57 | static bool addPacket(ENetPacket *packet, ENetPeer *peer); |
---|
| 58 | bool sendPackets(); |
---|
| 59 | ENetHost* getHost(){ return this->host_; } |
---|
| 60 | |
---|
| 61 | protected: |
---|
| 62 | Connection(); |
---|
| 63 | static Connection* getInstance(){ return Connection::instance_; } |
---|
| 64 | |
---|
[3209] | 65 | int service(ENetEvent* event); |
---|
| 66 | void disconnectPeer(ENetPeer *peer); |
---|
[3201] | 67 | |
---|
| 68 | void processQueue(); |
---|
| 69 | virtual void addClient(ENetEvent* event)=0; |
---|
[3202] | 70 | virtual void disconnectPeer(ENetEvent* event)=0; |
---|
[3209] | 71 | virtual bool processPacket(ENetEvent* event); |
---|
[3201] | 72 | |
---|
| 73 | ENetHost *host_; |
---|
| 74 | private: |
---|
| 75 | ENetAddress *bindAddress_; |
---|
| 76 | |
---|
| 77 | static Connection *instance_; |
---|
| 78 | |
---|
| 79 | }; |
---|
| 80 | |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | #endif /* _Connection_H__ */ |
---|