Last change
on this file since 7767 was
7767,
checked in by rennerc, 18 years ago
|
hover registers sync vars. started with connection monitor
|
File size:
1.4 KB
|
Rev | Line | |
---|
[5523] | 1 | /*! |
---|
| 2 | * @file connection_monitor.h |
---|
| 3 | \brief provides information about the quality of a connection. |
---|
[5550] | 4 | */ |
---|
[5523] | 5 | |
---|
[5550] | 6 | #ifndef _CONNECTION_MONITOR_H |
---|
| 7 | #define _CONNECTION_MONITOR_H |
---|
[5523] | 8 | |
---|
[5581] | 9 | #include "base_object.h" |
---|
[5550] | 10 | #include "netdefs.h" |
---|
[5547] | 11 | |
---|
[7767] | 12 | #include <map> |
---|
| 13 | |
---|
| 14 | #define N_PACKETS_FOR_PING 20 |
---|
| 15 | #define MSECS_TO_CALC_BWIDTH 1000 |
---|
| 16 | #define SECS_TO_TIMEOUT 10 |
---|
| 17 | |
---|
[5581] | 18 | class ConnectionMonitor : virtual public BaseObject |
---|
[7767] | 19 | { |
---|
[5618] | 20 | public: |
---|
[7767] | 21 | ConnectionMonitor( int userId ); |
---|
[6981] | 22 | virtual ~ConnectionMonitor(); |
---|
[5523] | 23 | |
---|
[7767] | 24 | void processUnzippedOutgoingPacket( byte * data, int length, int stateId ); |
---|
| 25 | void processUnzippedIncomingPacket( byte * data, int length, int stateId, int ackedState ); |
---|
| 26 | void processZippedPacket( ); |
---|
| 27 | |
---|
| 28 | void calculatePing(); |
---|
| 29 | |
---|
| 30 | bool hasTimedOut(){ return ( lastPacketTick + SECS_TO_TIMEOUT*1000 < SDL_GetTicks() ) && nIncomingPackets > 0; } |
---|
| 31 | |
---|
[5618] | 32 | private: |
---|
[7767] | 33 | float calculateBandWidth( std::map<int,int> packetHistory, int tick ); |
---|
| 34 | |
---|
| 35 | int userId; //!< user's id |
---|
[5523] | 36 | |
---|
[7767] | 37 | std::map<int,int> sentStateTicks; |
---|
| 38 | |
---|
| 39 | std::map<int,int> incomingUnzippedPacketHistory; |
---|
| 40 | std::map<int,int> outgoingUnzippedPacketHistory; |
---|
| 41 | |
---|
| 42 | std::list<int> ackDelay; |
---|
| 43 | int ping; |
---|
[5581] | 44 | |
---|
[7767] | 45 | float incomingUnzippedBandWidth; |
---|
| 46 | float outgoingUnzippedBandWidth; |
---|
| 47 | |
---|
| 48 | int nIncomingPackets; |
---|
| 49 | int nOutgoingPackets; |
---|
| 50 | |
---|
| 51 | int lastPacketTick; |
---|
[5618] | 52 | }; |
---|
[5550] | 53 | |
---|
| 54 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.