Skip to content

Commit

Permalink
Show server IP on timeout banner
Browse files Browse the repository at this point in the history
  • Loading branch information
tansly committed Jul 17, 2019
1 parent b1da700 commit 616f6f1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/frontend/stmclient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ void STMClient::init( void )
wstring escape_key_name = std::wstring(tmp.begin(), tmp.end());
escape_key_help = L"Commands: Ctrl-Z suspends, \".\" quits, " + escape_pass_name + L" gives literal " + escape_key_name;
overlays.get_notification_engine().set_escape_key_string( tmp );
overlays.get_notification_engine().server_address( ip );
}
wchar_t tmp[ 128 ];
swprintf( tmp, 128, L"Nothing received from server on UDP port %s.", port.c_str() );
Expand Down
10 changes: 5 additions & 5 deletions src/frontend/terminaloverlay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ void NotificationEngine::apply( Framebuffer &fb ) const

double since_heard = (double)(now - last_word_from_server) / 1000.0;
double since_ack = (double)(now - last_acked_state) / 1000.0;
const char server_message[] = "contact";
const char reply_message[] = "reply";
const char server_message[] = "contact with";
const char reply_message[] = "reply from";

double time_elapsed = since_heard;
const char *explanation = server_message;
Expand All @@ -235,17 +235,17 @@ void NotificationEngine::apply( Framebuffer &fb ) const
return;
}
if ( message.empty() && time_expired ) {
swprintf( tmp, 128, L"mosh: Last %s %s ago.%s", explanation,
swprintf( tmp, 128, L"mosh: Last %s %s %s ago.%s", explanation, server_addr.c_str(),
human_readable_duration( static_cast<int>( time_elapsed ),
"seconds" ).c_str(),
keystroke_str );
} else if ( (!message.empty()) && (!time_expired) ) {
swprintf( tmp, 128, L"mosh: %ls%s", message.c_str(), keystroke_str );
} else {
swprintf( tmp, 128, L"mosh: %ls (%s without %s.)%s", message.c_str(),
swprintf( tmp, 128, L"mosh: %ls (%s without %s %s.)%s", message.c_str(),
human_readable_duration( static_cast<int>( time_elapsed ),
"s" ).c_str(),
explanation, keystroke_str );
explanation, server_addr.c_str(), keystroke_str );
}

wstring string_to_draw( tmp );
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/terminaloverlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ namespace Overlay {
private:
uint64_t last_word_from_server;
uint64_t last_acked_state;
string server_addr;
string escape_key_string;
wstring message;
bool message_is_network_error;
Expand All @@ -157,6 +158,7 @@ namespace Overlay {
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; }
void server_address( const std::string &addr ) { server_addr = addr; }
int wait_time( void ) const;

void set_notification_string( const wstring &s_message, bool permanent = false, bool s_show_quit_keystroke = true )
Expand Down

0 comments on commit 616f6f1

Please sign in to comment.