diff --git a/networktransport.cpp b/networktransport.cpp index 0b83f1a..d1f8190 100644 --- a/networktransport.cpp +++ b/networktransport.cpp @@ -15,7 +15,8 @@ Transport::Transport( MyState &initial_state, RemoteState assumed_receiver_state( sent_states.begin() ), received_states( 1, TimestampedState( timestamp(), 0, initial_remote ) ), last_receiver_state( initial_remote ), - fragments() + fragments(), + verbose( false ) { /* server */ } @@ -30,7 +31,8 @@ Transport::Transport( MyState &initial_state, RemoteState assumed_receiver_state( sent_states.begin() ), received_states( 1, TimestampedState( timestamp(), 0, initial_remote ) ), last_receiver_state( initial_remote ), - fragments() + fragments(), + verbose( false ) { /* client */ } @@ -300,5 +302,11 @@ void Transport::send_in_fragments( string diff, uint64_t n string s = inst.tostring(); connection.send( s, send_timestamp ); + + if ( verbose ) { + fprintf( stderr, "Sent [%d=>%d] frag %d, ack=%d, throwaway=%d, len=%d\n", + (int)inst.old_num, (int)inst.new_num, (int)inst.fragment_num, + (int)inst.ack_num, (int)inst.throwaway_num, (int)inst.diff.size() ); + } } while ( !diff.empty() ); } diff --git a/networktransport.hpp b/networktransport.hpp index 92e94a3..7c3234c 100644 --- a/networktransport.hpp +++ b/networktransport.hpp @@ -109,6 +109,8 @@ namespace Network { FragmentAssembly fragments; + bool verbose; + public: Transport( MyState &initial_state, RemoteState &initial_remote ); Transport( MyState &initial_state, RemoteState &initial_remote, @@ -132,6 +134,8 @@ namespace Network { uint64_t get_remote_state_num( void ) { return received_states.back().num; } int fd( void ) { return connection.fd(); } + + void set_verbose( void ) { verbose = true; } }; } diff --git a/stm-server.cpp b/stm-server.cpp index 5d8ebd8..307da92 100644 --- a/stm-server.cpp +++ b/stm-server.cpp @@ -118,6 +118,8 @@ void serve( int host_fd ) Network::UserStream blank; Network::Transport< Terminal::Complete, Network::UserStream > network( terminal, blank ); + network.set_verbose(); + printf( "key= %s port= %d\n", network.get_key().c_str(), network.port() ); /* prepare to poll for events */ diff --git a/stm.cpp b/stm.cpp index 6bf8d0a..0c4457d 100644 --- a/stm.cpp +++ b/stm.cpp @@ -112,7 +112,7 @@ void client( const char *ip, int port, const char *key ) return; } - /* XXX transmit initial resize */ + /* XXX transmit initial resize and initialize */ /* local state */ Terminal::Complete terminal( window_size.ws_col, window_size.ws_row ); @@ -180,8 +180,7 @@ void client( const char *ip, int port, const char *key ) if ( (pollfds[ 0 ].revents | pollfds[ 1 ].revents) & (POLLERR | POLLHUP | POLLNVAL) ) { - perror( "poll" ); - // break; + break; } } } diff --git a/terminalframebuffer.hpp b/terminalframebuffer.hpp index 8704c9d..708630a 100644 --- a/terminalframebuffer.hpp +++ b/terminalframebuffer.hpp @@ -155,7 +155,9 @@ namespace Terminal { bool operator==( const DrawState &x ) const { /* XXX other fields not necessary to compare -- for now */ - return ( width == x.width ) && ( height == x.height ) && ( renditions == x.renditions ); + return ( width == x.width ) && ( height == x.height ) && ( cursor_col == x.cursor_col ) + && ( cursor_row == x.cursor_row ) && ( cursor_visible == x.cursor_visible ) && + ( reverse_video == x.reverse_video ) && ( renditions == x.renditions ); } };