Implemented socket message templates. (#40)

Implemented socket message templates to support broadcast (shared_ptr) and to achieve buffer zero-copy.
This commit is contained in:
Ravin Perera
2019-10-23 13:04:57 +05:30
committed by GitHub
parent b4237f1285
commit 61b38bb0a0
16 changed files with 636 additions and 539 deletions

View File

@@ -202,9 +202,9 @@ int verify_user_challenge_response(std::string &extracted_pubkeyhex, std::string
* @param pubkey User's binary public key.
* @return 0 on successful additions. -1 on failure.
*/
int add_user(sock::socket_session *session, const std::string &pubkey)
int add_user(sock::socket_session<user_outbound_message> *session, const std::string &pubkey)
{
const std::string &sessionid = session->uniqueid_;
const std::string &sessionid = session->uniqueid;
if (users.count(sessionid) == 1)
{
LOG_INFO << sessionid << " already exist. Cannot add user.";
@@ -249,7 +249,7 @@ int remove_user(const std::string &sessionid)
void start_listening()
{
auto address = net::ip::make_address(conf::cfg.listenip);
std::make_shared<sock::socket_server>(
std::make_shared<sock::socket_server<user_outbound_message>>(
ioc,
tcp::endpoint{address, conf::cfg.pubport},
global_usr_session_handler)