Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Name the server on timeout banner #1055

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
11 changes: 6 additions & 5 deletions src/frontend/terminaloverlay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ void ConditionalCursorMove::apply( Framebuffer &fb, uint64_t confirmed_epoch ) c
NotificationEngine::NotificationEngine()
: last_word_from_server( timestamp() ),
last_acked_state( timestamp() ),
server_addr(),
escape_key_string(),
message(),
message_is_network_error( false ),
Expand Down Expand Up @@ -216,8 +217,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 +236,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