Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/tutorialFS09/src/network/PacketBuffer.h @ 8879

Last change on this file since 8879 was 2756, checked in by rgrieder, 16 years ago

Minimising problems when including windows.h because it defines macros like "min" and "max" if not explicitly specified.
There are two headers we use that include windows.h: OgreWindowEventUtilities.h and enet.h. I had to tweak a little bit there as well.

  • Property svn:eol-style set to native
File size: 2.1 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, (C) 2007
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29//
30// C++ Interface: PacketBuffer
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
41#ifndef _PacketBuffer_H__
42#define _PacketBuffer_H__
43
44#include "NetworkPrereqs.h"
45
46#ifndef WIN32_LEAN_AND_MEAN
47#  define WIN32_LEAN_AND_MEAN
48#endif
49#define NOMINMAX // required to stop windows.h screwing up std::min definition
50#include <enet/enet.h>
51#include <boost/thread/recursive_mutex.hpp>
52
53namespace orxonox
54{
55  struct _NetworkExport PacketEnvelope{
56    int length;
57    int data;
58  };
59
60  struct _NetworkExport QueueItem{
61    ENetEvent *event;
62    //ENetAddress address;
63    QueueItem *next;
64  };
65
66  class _NetworkExport PacketBuffer{
67  public:
68    PacketBuffer();
69    bool isEmpty();
70    bool isClosed();
71    void setClosed(bool value);
72    void print();
73    // pops a packet from the queue
74    //ENetPacket *pop();
75    //ENetPacket *pop(ENetAddress &address);
76    ENetEvent *pop();
77    // pushs a packet to the queue
78    bool push(ENetEvent *ev);
79
80  private:
81    QueueItem *first;
82    QueueItem *last;
83    bool closed;
84    static boost::recursive_mutex mutex_;
85  };
86
87} //namespace
88#endif /* _PacketBuffer_H__ */
Note: See TracBrowser for help on using the repository browser.