Add CppCon2018 chat server example and video

This commit is contained in:
Vinnie Falco
2018-11-08 13:12:33 -08:00
parent e7e3fdb808
commit bc2f5f1426
30 changed files with 1134 additions and 14 deletions

View File

@@ -0,0 +1,41 @@
//
// Copyright (c) 2018 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/vinniefalco/CppCon2018
//
#include "shared_state.hpp"
#include "websocket_session.hpp"
shared_state::
shared_state(std::string doc_root)
: doc_root_(std::move(doc_root))
{
}
void
shared_state::
join(websocket_session& session)
{
sessions_.insert(&session);
}
void
shared_state::
leave(websocket_session& session)
{
sessions_.erase(&session);
}
void
shared_state::
send(std::string message)
{
auto const ss = std::make_shared<std::string const>(std::move(message));
for(auto session : sessions_)
session->send(ss);
}