Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 22, 2010, 7:24:24 PM (13 years ago)
Author:
dafrick
Message:

Merging presentation2 branch back to trunk.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/network/Connection.h

    r7163 r7801  
    4343#include "NetworkPrereqs.h"
    4444
     45#include <deque>
     46#include <enet/enet.h>
     47
     48namespace boost
     49{
     50  class thread;
     51  class mutex;
     52}
     53
    4554namespace orxonox
    4655{
    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;
    52 
    53   class _NetworkExport Connection{
     56  const unsigned int NETWORK_PORT                   = 55556;
     57  const unsigned int NETWORK_MAX_CONNECTIONS        = 50;
     58  const unsigned int NETWORK_WAIT_TIMEOUT           = 1;
     59  const unsigned int NETWORK_MAX_QUEUE_PROCESS_TIME = 5;
     60 
     61  namespace outgoingEventType
     62  {
     63    enum Value
     64    {
     65      sendPacket      = 1,
     66      disconnectPeer  = 2,
     67      broadcastPacket = 3
     68    };
     69   
     70  }
     71 
     72  struct _NetworkExport outgoingEvent
     73  {
     74    ENetPeer*                 peer;
     75    outgoingEventType::Value  type;
     76    ENetPacket*               packet;
     77    ENetChannelID             channelID;
     78  };
     79 
     80  class _NetworkExport Connection
     81  {
    5482  public:
    5583    virtual ~Connection();
    5684
    57     static bool addPacket(ENetPacket *packet, ENetPeer *peer);
    58     bool sendPackets();
    59     ENetHost* getHost(){ return this->host_; }
     85    void addPacket(ENetPacket *packet, ENetPeer *peer, uint8_t channelID);
     86    void broadcastPacket(ENetPacket* packet, uint8_t channelID);
     87//     ENetHost* getHost(){ return this->host_; }
    6088
    6189  protected:
     
    6391//     static Connection* getInstance(){ return Connection::instance_; }
    6492
    65     int service(ENetEvent* event);
     93//     int service(ENetEvent* event);
     94    void startCommunicationThread();
     95    void stopCommunicationThread();
     96    void communicationThread();
    6697    virtual void disconnectPeer(ENetPeer *peer);
     98   
     99    void enableCompression();
    67100
    68101    void processQueue();
    69102    virtual void addPeer(ENetEvent* event)=0;
    70103    virtual void removePeer(ENetEvent* event)=0;
    71     virtual bool processPacket(ENetEvent* event);
     104    virtual void processPacket( packet::Packet* packet)=0;
     105    virtual packet::Packet* createPacket(ENetEvent* event);
    72106
    73     ENetHost *host_;
     107    ENetHost*                   host_;
    74108  private:
    75     ENetAddress *bindAddress_;
     109    boost::thread*              communicationThread_;
     110    bool                        bCommunicationThreadRunning_;
     111    ENetAddress*                bindAddress_;
     112    std::deque<ENetEvent>       incomingEvents_;
     113    std::deque<outgoingEvent>   outgoingEvents_;
     114    boost::mutex*               incomingEventsMutex_;
     115    boost::mutex*               outgoingEventsMutex_;
    76116
    77117//     static Connection *instance_;
Note: See TracChangeset for help on using the changeset viewer.