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:
36
src/p2p/peer_comm_session.cpp
Normal file
36
src/p2p/peer_comm_session.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "../pchheader.hpp"
|
||||
#include "peer_comm_session.hpp"
|
||||
#include "peer_session_handler.hpp"
|
||||
|
||||
namespace p2p
|
||||
{
|
||||
void peer_comm_session::handle_connect()
|
||||
{
|
||||
p2p::handle_peer_connect(*this);
|
||||
}
|
||||
|
||||
int peer_comm_session::handle_message(std::string_view msg)
|
||||
{
|
||||
return p2p::handle_peer_message(*this, msg);
|
||||
}
|
||||
|
||||
void peer_comm_session::handle_close()
|
||||
{
|
||||
p2p::handle_peer_close(*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns printable name for the session based on uniqueid (used for logging).
|
||||
*/
|
||||
const std::string peer_comm_session::display_name()
|
||||
{
|
||||
if (challenge_status == comm::CHALLENGE_STATUS::CHALLENGE_VERIFIED)
|
||||
{
|
||||
// Peer sessions use pubkey hex as unique id (skipping first 2 bytes key type prefix).
|
||||
return uniqueid.substr(2, 10) + (is_inbound ? ":in" : ":out");
|
||||
}
|
||||
|
||||
return comm_session::display_name();
|
||||
}
|
||||
|
||||
} // namespace p2p
|
||||
Reference in New Issue
Block a user