Dynamic peer list implementation. (#152)

This commit is contained in:
Chalith Desaman
2020-11-18 12:58:58 +05:30
committed by GitHub
parent 1608e9fc49
commit f475dcb1fb
21 changed files with 848 additions and 71 deletions

View File

@@ -31,17 +31,25 @@ namespace comm
/**
* Init() should be called to activate the session.
* Because we are starting threads here, after init() is called, the session object must not be "std::moved".
* @return returns 0 on successful init, otherwise -1;
*/
void comm_session::init()
int comm_session::init()
{
if (state == SESSION_STATE::NONE)
{
handle_connect();
if (handle_connect() == -1)
{
mark_for_closure();
return -1;
}
reader_thread = std::thread(&comm_session::reader_loop, this);
writer_thread = std::thread(&comm_session::process_outbound_msg_queue, this);
state = SESSION_STATE::ACTIVE;
last_activity_timestamp = util::get_epoch_milliseconds();
}
return 0;
}
void comm_session::reader_loop()
@@ -297,8 +305,9 @@ namespace comm
}
}
void comm_session::handle_connect()
int comm_session::handle_connect()
{
return 0;
}
int comm_session::handle_message(std::string_view msg)