Skip to content
Merged
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
5 changes: 5 additions & 0 deletions Common/Cpp/Sockets/AbstractClientSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ class AbstractClientSocket{

// Called when the socket receives data from the server.
virtual void on_receive_data(const void* data, size_t bytes){}

// Called when an established connection is lost (the server closed
// the connection or a socket error occurred). It is not called by
// "close()".
virtual void on_disconnect(const std::string& error_message){}
};

void add_listener(Listener& listener){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void TcpSysbotBase_Connection::thread_loop(){
void TcpSysbotBase_Connection::on_connect_finished(const std::string& error_message){
try{
if (!error_message.empty()){
m_logger.log(m_connecting_message, COLOR_RED);
m_logger.log(m_connecting_message + " - " + error_message, COLOR_RED);
set_status_line0(m_connecting_message, COLOR_RED);
return;
}
Expand All @@ -162,6 +162,12 @@ void TcpSysbotBase_Connection::on_connect_finished(const std::string& error_mess
write_data("getVersion\r\n");
}catch (...){}
}
void TcpSysbotBase_Connection::on_disconnect(const std::string& error_message){
try{
m_logger.log("sys-botbase disconnected: " + error_message, COLOR_RED);
set_status_line1("Disconnected: " + error_message, COLOR_RED);
}catch (...){}
}
void TcpSysbotBase_Connection::on_receive_data(const void* data, size_t bytes){
// cout << "on_receive_data(): " << std::string((const char*)data, bytes - 2) << endl;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class TcpSysbotBase_Connection : public ControllerConnection, private ClientSock

virtual void on_connect_finished(const std::string& error_message) override;
virtual void on_receive_data(const void* data, size_t bytes) override;
virtual void on_disconnect(const std::string& error_message) override;

void process_message(const std::string& message, WallClock timestamp);
void set_mode(const std::string& sbb_version);
Expand Down
Loading