Warn when server has not heard from us (even if we have heard from server)

This commit is contained in:
Keith Winstein
2012-04-30 22:43:45 -04:00
parent e70254bad5
commit 2ea3f3a347
5 changed files with 29 additions and 4 deletions
+5 -1
View File
@@ -127,16 +127,20 @@ namespace Overlay {
class NotificationEngine {
private:
uint64_t last_word_from_server;
uint64_t last_acked_state;
wstring message;
uint64_t message_expiration;
public:
bool need_countup( uint64_t ts ) const { return ts - last_word_from_server > 6500; }
bool server_late( uint64_t ts ) const { return (ts - last_word_from_server) > 6500; }
bool reply_late( uint64_t ts ) const { return (ts - last_acked_state) > 10000; }
bool need_countup( uint64_t ts ) const { return server_late( ts ) || reply_late( ts ); }
void adjust_message( void );
void apply( Framebuffer &fb ) const;
void set_notification_string( const wstring &s_message, bool permanent = false ) { message = s_message; if ( permanent ) { message_expiration = -1; } else { message_expiration = timestamp() + 1000; } }
const wstring &get_notification_string( void ) const { return message; }
void server_heard( uint64_t s_last_word ) { last_word_from_server = s_last_word; }
void server_acked( uint64_t s_last_acked ) { last_acked_state = s_last_acked; }
uint64_t get_message_expiration( void ) const { return message_expiration; }
NotificationEngine();