Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 30, 2015, 11:34:25 PM (8 years ago)
Author:
landauf
Message:

made some enums in network library strongly typed. for most other enums in network this isn't possible because they are often used like flags (converted to int and compared with binary operators).
packet::Type now uses uint8_t as underlying type which reduces the network traffic (by default the type was int)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/libraries/network/Connection.h

    r10774 r11006  
    6060  const unsigned int NETWORK_MAX_QUEUE_PROCESS_TIME = 5;
    6161 
    62   namespace incomingEventType
     62  enum class IncomingEventType
    6363  {
    64     enum Value
    65     {
    66       receivePacket   = 1,  // incoming packet
    67       peerConnect     = 2,  // incoming connect request
    68       peerDisconnect  = 3   // incoming disconnect request
    69     };
    70    
    71   }
     64    receivePacket   = 1,  // incoming packet
     65    peerConnect     = 2,  // incoming connect request
     66    peerDisconnect  = 3   // incoming disconnect request
     67  };
    7268 
    73   namespace outgoingEventType
     69  enum class OutgoingEventType
    7470  {
    75     enum Value
    76     {
    77       sendPacket      = 1,  // outgoing packet
    78       broadcastPacket = 2,  // outgoing broadcast packet
    79       disconnectPeer  = 3,  // outgoing disconnect request
    80       disconnectPeers = 4   // outgoing disconnect request
    81     };
    82    
    83   }
     71    sendPacket      = 1,  // outgoing packet
     72    broadcastPacket = 2,  // outgoing broadcast packet
     73    disconnectPeer  = 3,  // outgoing disconnect request
     74    disconnectPeers = 4   // outgoing disconnect request
     75  };
    8476 
    8577  struct _NetworkExport incomingEvent
    8678  {
    87     uint32_t                  peerID;
    88     incomingEventType::Value type;
    89     packet::Packet*           packet;
     79    uint32_t          peerID;
     80    IncomingEventType type;
     81    packet::Packet*   packet;
    9082  };
    9183 
    9284  struct _NetworkExport outgoingEvent
    9385  {
    94     uint32_t                  peerID;
    95     outgoingEventType::Value type;
    96     ENetPacket*               packet;
    97     ENetChannelID             channelID;
     86    uint32_t          peerID;
     87    OutgoingEventType type;
     88    ENetPacket*       packet;
     89    ENetChannelID     channelID;
    9890  };
    9991 
Note: See TracChangeset for help on using the changeset viewer.