mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Refactored socket send method and message recieved method (#25)
* Enhanced sockets * Removed unnecessary copy operations * Enhanced sock session send method to recieve rref * Enhanced on_read with rvalue reference * Added string_view * Added comments
This commit is contained in:
@@ -24,7 +24,7 @@ void user_session_handler::on_connect(sock::socket_session *session)
|
||||
{
|
||||
std::cout << "User client connected " << session->address_ << ":" << session->port_ << std::endl;
|
||||
|
||||
// As a soon as a user conntects, we issue them a challenge message. We remember the
|
||||
// As soon as a user conntects, we issue them a challenge message. We remember the
|
||||
// challenge we issued and later verifies the user's response with it.
|
||||
|
||||
std::string msg;
|
||||
@@ -37,8 +37,7 @@ void user_session_handler::on_connect(sock::socket_session *session)
|
||||
// Create an entry in pending_challenges for later tracking upon challenge response.
|
||||
usr::pending_challenges[session->uniqueid_] = challengeb64;
|
||||
|
||||
// TODO: This needs to be reviewed to optimise passing the message.
|
||||
session->send(std::make_shared<std::string>(msg));
|
||||
session->send(std::move(msg));
|
||||
|
||||
// Set the challenge-issued flag to help later checks in on_message.
|
||||
session->flags_.set(util::SESSION_FLAG::USER_CHALLENGE_ISSUED);
|
||||
@@ -47,7 +46,7 @@ void user_session_handler::on_connect(sock::socket_session *session)
|
||||
/**
|
||||
* This gets hit every time we receive some data from a client connected to the HP public port.
|
||||
*/
|
||||
void user_session_handler::on_message(sock::socket_session *session, const std::string &message)
|
||||
void user_session_handler::on_message(sock::socket_session *session, std::string &&message)
|
||||
{
|
||||
// First check whether this session is pending challenge.
|
||||
// Meaning we have previously issued a challenge to the client,
|
||||
|
||||
Reference in New Issue
Block a user