mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Comm session re-architecture and self comm channel. (#145)
* Introduced self comm channel instead of loopback websocket. * Introduced comm_session and comm_server inheritance hierarchy. * Separated peer session and user session classes.
This commit is contained in:
41
src/usr/user_comm_session.cpp
Normal file
41
src/usr/user_comm_session.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "../pchheader.hpp"
|
||||
#include "../util.hpp"
|
||||
#include "user_comm_session.hpp"
|
||||
#include "user_session_handler.hpp"
|
||||
|
||||
namespace usr
|
||||
{
|
||||
void user_comm_session::handle_connect()
|
||||
{
|
||||
usr::handle_user_connect(*this);
|
||||
}
|
||||
|
||||
int user_comm_session::handle_message(std::string_view msg)
|
||||
{
|
||||
return usr::handle_user_message(*this, msg);
|
||||
}
|
||||
|
||||
void user_comm_session::handle_close()
|
||||
{
|
||||
usr::handle_user_close(*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns printable name for the session based on uniqueid (used for logging).
|
||||
*/
|
||||
const std::string user_comm_session::display_name()
|
||||
{
|
||||
if (challenge_status == comm::CHALLENGE_STATUS::CHALLENGE_VERIFIED)
|
||||
{
|
||||
// User sessions use binary pubkey as unique id. So we need to convert to hex.
|
||||
std::string hex;
|
||||
util::bin2hex(hex,
|
||||
reinterpret_cast<const unsigned char *>(uniqueid.data()),
|
||||
uniqueid.length());
|
||||
return hex.substr(2, 10) + (is_inbound ? ":in" : ":out"); // Skipping first 2 bytes key type prefix.
|
||||
}
|
||||
|
||||
return comm_session::display_name();
|
||||
}
|
||||
|
||||
} // namespace usr
|
||||
Reference in New Issue
Block a user