Changed api to allow user to create clients and syncers at will.
This commit is contained in:
parent
2f8bb781a1
commit
6634f30c28
@ -25,7 +25,7 @@
|
|||||||
#include "raii/filerd.hpp"
|
#include "raii/filerd.hpp"
|
||||||
#include "matrix/session_info.hpp"
|
#include "matrix/session_info.hpp"
|
||||||
#include "matrix/upload_info.hpp"
|
#include "matrix/upload_info.hpp"
|
||||||
#include "matrix/client_base.hpp"
|
#include "matrix/connection.hpp"
|
||||||
#include <vector> //vector
|
#include <vector> //vector
|
||||||
#include <memory> //shared_ptr
|
#include <memory> //shared_ptr
|
||||||
#include <cstdlib> //size_t
|
#include <cstdlib> //size_t
|
||||||
@ -33,14 +33,11 @@
|
|||||||
namespace matrix{
|
namespace matrix{
|
||||||
class session;
|
class session;
|
||||||
//main class
|
//main class
|
||||||
class client : public internal::client_base
|
class client : public connection
|
||||||
{
|
{
|
||||||
friend class ::matrix::session;
|
friend class ::matrix::session;
|
||||||
private:
|
|
||||||
const std::shared_ptr<internal::session_info> m_ses;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
client(std::shared_ptr<internal::session_info>&);
|
client(const std::shared_ptr<internal::session_info>&);
|
||||||
client(const client& b) = default;
|
client(const client& b) = default;
|
||||||
client(client&& b) = default;
|
client(client&& b) = default;
|
||||||
~client(void) = default;
|
~client(void) = default;
|
||||||
|
|||||||
@ -16,30 +16,35 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MATRIX_CLIENT_BASE_HPP
|
#ifndef MATRIX_CONNECTION_HPP
|
||||||
#define MATRIX_CLIENT_BASE_HPP
|
#define MATRIX_CONNECTION_HPP
|
||||||
|
|
||||||
#include "raii/curler.hpp"
|
#include "raii/curler.hpp"
|
||||||
#include "raii/string.hpp"
|
#include "raii/string.hpp"
|
||||||
#include "raii/rjp_string.hpp"
|
#include "raii/rjp_string.hpp"
|
||||||
|
#include "matrix/session_info.hpp"
|
||||||
|
#include <memory> //shared_ptr
|
||||||
|
|
||||||
namespace matrix::internal{
|
namespace matrix{
|
||||||
|
|
||||||
class client_base
|
class connection
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
mutable raii::curler m_curl;
|
mutable raii::curler m_curl;
|
||||||
|
std::shared_ptr<internal::session_info> m_ses;
|
||||||
protected:
|
protected:
|
||||||
client_base(void);
|
connection(const std::shared_ptr<internal::session_info>&);
|
||||||
client_base(const client_base&) = default;
|
connection(const connection&) = default;
|
||||||
client_base(client_base&&) = default;
|
connection(connection&&) = default;
|
||||||
~client_base(void) = default;
|
connection& operator=(const connection&) = default;
|
||||||
client_base& operator=(const client_base&) = default;
|
connection& operator=(connection&&) = default;
|
||||||
client_base& operator=(client_base&&) = default;
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
~connection(void) = default;
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
void _set_curl_useragent(const raii::string_base& useragent);
|
void _set_curl_useragent(const raii::string_base& useragent);
|
||||||
|
|
||||||
protected:
|
|
||||||
static size_t _post_reply_curl_callback(char* ptr, size_t size, size_t nmemb, void* userdata);
|
static size_t _post_reply_curl_callback(char* ptr, size_t size, size_t nmemb, void* userdata);
|
||||||
raii::string _get_curl(const raii::string_base& url)const;
|
raii::string _get_curl(const raii::string_base& url)const;
|
||||||
raii::string _post_curl(const raii::string_base& postdata, const raii::string_base& url, const raii::curl_llist& header)const;
|
raii::string _post_curl(const raii::string_base& postdata, const raii::string_base& url, const raii::curl_llist& header)const;
|
||||||
@ -23,30 +23,25 @@
|
|||||||
#include "matrix/syncer.hpp"
|
#include "matrix/syncer.hpp"
|
||||||
#include "matrix/session_info.hpp"
|
#include "matrix/session_info.hpp"
|
||||||
#include "matrix/auth.hpp"
|
#include "matrix/auth.hpp"
|
||||||
|
#include "raii/curler.hpp"
|
||||||
#include "raii/string.hpp"
|
#include "raii/string.hpp"
|
||||||
#include <memory> //shared_ptr
|
#include "matrix/connection.hpp"
|
||||||
#include <utility> //pair
|
#include <utility> //pair
|
||||||
|
|
||||||
namespace matrix{
|
namespace matrix{
|
||||||
class session
|
class session : protected connection
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
std::shared_ptr<internal::session_info> m_ses;
|
|
||||||
client m_client;
|
|
||||||
syncer m_sync;
|
|
||||||
public:
|
public:
|
||||||
session(const auth_data&);
|
session(const auth_data&);
|
||||||
//local setter
|
//local setter
|
||||||
void set_useragent(const raii::string_base&);
|
void set_useragent(const raii::string_base&);
|
||||||
void set_useragent(raii::string&&);
|
void set_useragent(raii::string&&);
|
||||||
|
|
||||||
client& get_client(void);
|
|
||||||
const client& get_client(void)const;
|
|
||||||
syncer& get_syncer(void);
|
|
||||||
const syncer& get_syncer(void)const;
|
|
||||||
|
|
||||||
bool valid(void)const;
|
bool valid(void)const;
|
||||||
|
|
||||||
|
client create_client(void)const;
|
||||||
|
syncer create_syncer(void)const;
|
||||||
|
|
||||||
void invalidate(void);
|
void invalidate(void);
|
||||||
private:
|
private:
|
||||||
void _populate_session_info(const auth_data& a);
|
void _populate_session_info(const auth_data& a);
|
||||||
|
|||||||
@ -23,21 +23,20 @@
|
|||||||
#include "raii/rjp_string.hpp"
|
#include "raii/rjp_string.hpp"
|
||||||
#include "raii/string.hpp"
|
#include "raii/string.hpp"
|
||||||
#include "matrix/session_info.hpp"
|
#include "matrix/session_info.hpp"
|
||||||
#include "matrix/client_base.hpp"
|
#include "matrix/connection.hpp"
|
||||||
#include <cstdlib> //size_t
|
#include <cstdlib> //size_t
|
||||||
#include <memory> //shared_ptr
|
#include <memory> //shared_ptr
|
||||||
|
|
||||||
namespace matrix{
|
namespace matrix{
|
||||||
class session;
|
class session;
|
||||||
class syncer : public internal::client_base
|
class syncer : public connection
|
||||||
{
|
{
|
||||||
friend class ::matrix::session;
|
friend class ::matrix::session;
|
||||||
private:
|
private:
|
||||||
const std::shared_ptr<internal::session_info> m_ses;
|
|
||||||
raii::rjp_string m_next_batch; //string which tracks where we are in the server history
|
raii::rjp_string m_next_batch; //string which tracks where we are in the server history
|
||||||
|
|
||||||
public:
|
public:
|
||||||
syncer(std::shared_ptr<internal::session_info>&);
|
syncer(const std::shared_ptr<internal::session_info>&);
|
||||||
syncer(const syncer& b) = default;
|
syncer(const syncer& b) = default;
|
||||||
syncer(syncer&& b) = default;
|
syncer(syncer&& b) = default;
|
||||||
~syncer(void) = default;
|
~syncer(void) = default;
|
||||||
|
|||||||
@ -38,6 +38,8 @@ namespace raii{
|
|||||||
curler(curler&& c)noexcept;
|
curler(curler&& c)noexcept;
|
||||||
~curler(void);
|
~curler(void);
|
||||||
|
|
||||||
|
curler& operator=(const curler&);
|
||||||
|
curler& operator=(curler&&);
|
||||||
template<class T>
|
template<class T>
|
||||||
curler& setopt(CURLoption option, T&& t){
|
curler& setopt(CURLoption option, T&& t){
|
||||||
curl_easy_setopt(m_curl, option, t);
|
curl_easy_setopt(m_curl, option, t);
|
||||||
|
|||||||
@ -35,9 +35,8 @@
|
|||||||
namespace matrix{
|
namespace matrix{
|
||||||
|
|
||||||
//Ctor
|
//Ctor
|
||||||
client::client(std::shared_ptr<internal::session_info>& ses):
|
client::client(const std::shared_ptr<internal::session_info>& ses):
|
||||||
client_base(),
|
connection(ses){}
|
||||||
m_ses(ses){}
|
|
||||||
|
|
||||||
//local getter
|
//local getter
|
||||||
const raii::rjp_string& client::access_token(void)const{
|
const raii::rjp_string& client::access_token(void)const{
|
||||||
|
|||||||
@ -16,28 +16,29 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "matrix/client_base.hpp"
|
#include "matrix/connection.hpp"
|
||||||
#include "raii/rjp_ptr.hpp"
|
#include "raii/rjp_ptr.hpp"
|
||||||
#include "raii/static_string.hpp"
|
#include "raii/static_string.hpp"
|
||||||
#include <cstdlib> //size_t
|
#include <cstdlib> //size_t
|
||||||
#include <algorithm> //min, max
|
#include <algorithm> //min, max
|
||||||
|
|
||||||
namespace matrix::internal{
|
namespace matrix{
|
||||||
|
|
||||||
client_base::client_base(void):
|
connection::connection(const std::shared_ptr<internal::session_info>& ses):
|
||||||
m_curl()
|
m_curl(),
|
||||||
|
m_ses(ses)
|
||||||
{
|
{
|
||||||
_set_curl_defaults(""_ss);
|
_set_curl_defaults(""_ss);
|
||||||
}
|
}
|
||||||
void client_base::_set_curl_useragent(const raii::string_base& useragent){
|
void connection::_set_curl_useragent(const raii::string_base& useragent){
|
||||||
m_curl.setuseragent(useragent);
|
m_curl.setuseragent(useragent);
|
||||||
}
|
}
|
||||||
size_t client_base::_post_reply_curl_callback(char* ptr, size_t size, size_t nmemb, void* userdata){
|
size_t connection::_post_reply_curl_callback(char* ptr, size_t size, size_t nmemb, void* userdata){
|
||||||
raii::string* data = reinterpret_cast<raii::string*>(userdata);
|
raii::string* data = reinterpret_cast<raii::string*>(userdata);
|
||||||
(*data) += ptr;
|
(*data) += ptr;
|
||||||
return size*nmemb;
|
return size*nmemb;
|
||||||
}
|
}
|
||||||
raii::string client_base::_get_curl(const raii::string_base& url)const{
|
raii::string connection::_get_curl(const raii::string_base& url)const{
|
||||||
raii::string reply;
|
raii::string reply;
|
||||||
m_curl.getreq();
|
m_curl.getreq();
|
||||||
m_curl.seturl(url);
|
m_curl.seturl(url);
|
||||||
@ -49,7 +50,7 @@ namespace matrix::internal{
|
|||||||
return {};
|
return {};
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
raii::string client_base::_post_curl(const raii::string_base& postdata, const raii::string_base& url, const raii::curl_llist& header)const{
|
raii::string connection::_post_curl(const raii::string_base& postdata, const raii::string_base& url, const raii::curl_llist& header)const{
|
||||||
raii::string reply;
|
raii::string reply;
|
||||||
m_curl.postreq();
|
m_curl.postreq();
|
||||||
m_curl.setopt(CURLOPT_POSTFIELDS, postdata.get());
|
m_curl.setopt(CURLOPT_POSTFIELDS, postdata.get());
|
||||||
@ -76,7 +77,7 @@ namespace matrix::internal{
|
|||||||
src->data += to_copy;
|
src->data += to_copy;
|
||||||
return to_copy;
|
return to_copy;
|
||||||
}
|
}
|
||||||
raii::string client_base::_put_curl(const raii::string_base& putdata, const raii::string_base& url, const raii::curl_llist& header)const{
|
raii::string connection::_put_curl(const raii::string_base& putdata, const raii::string_base& url, const raii::curl_llist& header)const{
|
||||||
raii::string reply;
|
raii::string reply;
|
||||||
put_data data{putdata.get(), putdata.length()};
|
put_data data{putdata.get(), putdata.length()};
|
||||||
m_curl.putreq();
|
m_curl.putreq();
|
||||||
@ -96,7 +97,7 @@ namespace matrix::internal{
|
|||||||
return {};
|
return {};
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
raii::rjp_string client_base::_post_and_find(const raii::string_base& data, const raii::string_base& url,
|
raii::rjp_string connection::_post_and_find(const raii::string_base& data, const raii::string_base& url,
|
||||||
const raii::curl_llist& header, const raii::string_base& target)const
|
const raii::curl_llist& header, const raii::string_base& target)const
|
||||||
{
|
{
|
||||||
raii::string reply = _post_curl(data, url, header);
|
raii::string reply = _post_curl(data, url, header);
|
||||||
@ -104,13 +105,13 @@ namespace matrix::internal{
|
|||||||
return {};
|
return {};
|
||||||
return _curl_reply_search(reply, target);
|
return _curl_reply_search(reply, target);
|
||||||
}
|
}
|
||||||
raii::rjp_string client_base::_get_and_find(const raii::string_base& url, const raii::string_base& target)const{
|
raii::rjp_string connection::_get_and_find(const raii::string_base& url, const raii::string_base& target)const{
|
||||||
raii::string reply = _get_curl(url);
|
raii::string reply = _get_curl(url);
|
||||||
if(!reply)
|
if(!reply)
|
||||||
return {};
|
return {};
|
||||||
return _curl_reply_search(reply, target);
|
return _curl_reply_search(reply, target);
|
||||||
}
|
}
|
||||||
raii::rjp_string client_base::_curl_reply_search(const raii::string_base& reply, const raii::string_base& target)const{
|
raii::rjp_string connection::_curl_reply_search(const raii::string_base& reply, const raii::string_base& target)const{
|
||||||
raii::rjp_ptr root(rjp_parse(reply));
|
raii::rjp_ptr root(rjp_parse(reply));
|
||||||
if(!root)
|
if(!root)
|
||||||
return {};
|
return {};
|
||||||
@ -119,7 +120,7 @@ namespace matrix::internal{
|
|||||||
return {};
|
return {};
|
||||||
return raii::rjp_string(res.value);
|
return raii::rjp_string(res.value);
|
||||||
}
|
}
|
||||||
void client_base::_set_curl_defaults(const raii::string_base& useragent)const{
|
void connection::_set_curl_defaults(const raii::string_base& useragent)const{
|
||||||
m_curl.setopt(CURLOPT_BUFFERSIZE, 102400L);
|
m_curl.setopt(CURLOPT_BUFFERSIZE, 102400L);
|
||||||
m_curl.setopt(CURLOPT_NOPROGRESS, 1L);
|
m_curl.setopt(CURLOPT_NOPROGRESS, 1L);
|
||||||
m_curl.setuseragent(useragent);
|
m_curl.setuseragent(useragent);
|
||||||
@ -24,13 +24,10 @@
|
|||||||
namespace matrix{
|
namespace matrix{
|
||||||
|
|
||||||
session::session(const auth_data& auth):
|
session::session(const auth_data& auth):
|
||||||
m_ses(new internal::session_info),
|
connection(std::make_shared<internal::session_info>())
|
||||||
m_client(m_ses),
|
|
||||||
m_sync(m_ses)
|
|
||||||
{
|
{
|
||||||
_populate_session_info(auth);
|
_populate_session_info(auth);
|
||||||
m_client._set_curl_useragent(m_ses->useragent);
|
_set_curl_defaults(m_ses->useragent);
|
||||||
m_sync._set_curl_useragent(m_ses->useragent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void session::set_useragent(const raii::string_base& agent){
|
void session::set_useragent(const raii::string_base& agent){
|
||||||
@ -40,23 +37,16 @@ namespace matrix{
|
|||||||
m_ses->useragent = std::move(agent);
|
m_ses->useragent = std::move(agent);
|
||||||
}
|
}
|
||||||
|
|
||||||
client& session::get_client(void){
|
|
||||||
return m_client;
|
|
||||||
}
|
|
||||||
const client& session::get_client(void)const{
|
|
||||||
return m_client;
|
|
||||||
}
|
|
||||||
syncer& session::get_syncer(void){
|
|
||||||
return m_sync;
|
|
||||||
}
|
|
||||||
const syncer& session::get_syncer(void)const{
|
|
||||||
return m_sync;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool session::valid(void)const{
|
bool session::valid(void)const{
|
||||||
return m_ses->access_token;
|
return m_ses->access_token;
|
||||||
}
|
}
|
||||||
|
client session::create_client(void)const{
|
||||||
|
return client(m_ses);
|
||||||
|
}
|
||||||
|
syncer session::create_syncer(void)const{
|
||||||
|
return syncer(m_ses);
|
||||||
|
}
|
||||||
void session::invalidate(void){
|
void session::invalidate(void){
|
||||||
m_ses->useragent.reset();
|
m_ses->useragent.reset();
|
||||||
m_ses->homeserver.reset();
|
m_ses->homeserver.reset();
|
||||||
@ -69,7 +59,7 @@ namespace matrix{
|
|||||||
m_ses->useragent = a.useragent;
|
m_ses->useragent = a.useragent;
|
||||||
m_ses->homeserver = a.homeserver;
|
m_ses->homeserver = a.homeserver;
|
||||||
m_ses->access_token = a.access_token;
|
m_ses->access_token = a.access_token;
|
||||||
auto reply = m_client._get_curl(mat_url_list::stat_whoami(m_ses->homeserver, m_ses->access_token));
|
auto reply = _get_curl(mat_url_list::stat_whoami(m_ses->homeserver, m_ses->access_token));
|
||||||
if(!reply){
|
if(!reply){
|
||||||
auto [token, id] = _get_new_access_token(a.name, a.pass, mat_url_list::login(m_ses->homeserver));
|
auto [token, id] = _get_new_access_token(a.name, a.pass, mat_url_list::login(m_ses->homeserver));
|
||||||
if(token && id){
|
if(token && id){
|
||||||
@ -89,15 +79,14 @@ namespace matrix{
|
|||||||
CURLcode result;
|
CURLcode result;
|
||||||
raii::string postdata("{\"type\":\"m.login.password\", \"user\":\"" + raii::json_escape(name) + "\", \"password\":\"" + raii::json_escape(pass) + "\"}");
|
raii::string postdata("{\"type\":\"m.login.password\", \"user\":\"" + raii::json_escape(name) + "\", \"password\":\"" + raii::json_escape(pass) + "\"}");
|
||||||
raii::string reply;
|
raii::string reply;
|
||||||
raii::curler& cur = m_client.m_curl;
|
|
||||||
|
|
||||||
cur.seturl(loginurl);
|
m_curl.seturl(loginurl);
|
||||||
cur.setpostdata(postdata);
|
m_curl.setpostdata(postdata);
|
||||||
cur.postreq();
|
m_curl.postreq();
|
||||||
cur.setopt(CURLOPT_WRITEFUNCTION, client::_post_reply_curl_callback);
|
m_curl.setopt(CURLOPT_WRITEFUNCTION, client::_post_reply_curl_callback);
|
||||||
cur.setopt(CURLOPT_WRITEDATA, &reply);
|
m_curl.setopt(CURLOPT_WRITEDATA, &reply);
|
||||||
|
|
||||||
result = cur.perform();
|
result = m_curl.perform();
|
||||||
|
|
||||||
if(result != CURLE_OK)
|
if(result != CURLE_OK)
|
||||||
return {};
|
return {};
|
||||||
@ -105,7 +94,7 @@ namespace matrix{
|
|||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
raii::rjp_string session::_get_userid(void){
|
raii::rjp_string session::_get_userid(void){
|
||||||
auto reply = m_client._get_curl(mat_url_list::stat_whoami(m_ses->homeserver, m_ses->access_token));
|
auto reply = _get_curl(mat_url_list::stat_whoami(m_ses->homeserver, m_ses->access_token));
|
||||||
if(!reply)
|
if(!reply)
|
||||||
return {};
|
return {};
|
||||||
raii::rjp_ptr root(rjp_parse(reply));
|
raii::rjp_ptr root(rjp_parse(reply));
|
||||||
|
|||||||
@ -22,9 +22,8 @@
|
|||||||
#include "raii/util.hpp"
|
#include "raii/util.hpp"
|
||||||
|
|
||||||
namespace matrix{
|
namespace matrix{
|
||||||
syncer::syncer(std::shared_ptr<internal::session_info>& ses):
|
syncer::syncer(const std::shared_ptr<internal::session_info>& ses):
|
||||||
client_base(),
|
connection(ses){}
|
||||||
m_ses(ses){}
|
|
||||||
|
|
||||||
raii::string syncer::sync(size_t timeout){
|
raii::string syncer::sync(size_t timeout){
|
||||||
raii::string reply = _get_curl(m_ses->urls.sync(m_ses->homeserver, m_ses->access_token, m_next_batch, raii::itostr(timeout)));
|
raii::string reply = _get_curl(m_ses->urls.sync(m_ses->homeserver, m_ses->access_token, m_next_batch, raii::itostr(timeout)));
|
||||||
|
|||||||
@ -33,6 +33,14 @@ namespace raii{
|
|||||||
curl_easy_cleanup(m_curl);
|
curl_easy_cleanup(m_curl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
curler& curler::operator=(const curler& c){
|
||||||
|
curler tmp(c);
|
||||||
|
return *this = std::move(tmp);
|
||||||
|
}
|
||||||
|
curler& curler::operator=(curler&& c){
|
||||||
|
std::swap(m_curl, c.m_curl);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
curler& curler::putreq(void){
|
curler& curler::putreq(void){
|
||||||
setopt(CURLOPT_HTTPGET, 0L);
|
setopt(CURLOPT_HTTPGET, 0L);
|
||||||
setopt(CURLOPT_POST, 0L);
|
setopt(CURLOPT_POST, 0L);
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
#include <future>
|
#include <future>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
void sync_fn(matrix::syncer& syn, std::atomic_bool& should_quit){
|
void sync_fn(matrix::syncer syn, std::atomic_bool& should_quit){
|
||||||
auto sync_reply = syn.sync(0);
|
auto sync_reply = syn.sync(0);
|
||||||
|
|
||||||
while(!should_quit){
|
while(!should_quit){
|
||||||
@ -34,7 +34,7 @@ void sync_fn(matrix::syncer& syn, std::atomic_bool& should_quit){
|
|||||||
printf("%s\n", sync_reply.get());
|
printf("%s\n", sync_reply.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void keyboard_fn(matrix::client& client, std::atomic_bool& should_quit){
|
void keyboard_fn(matrix::client client, std::atomic_bool& should_quit){
|
||||||
char buffer[2048];
|
char buffer[2048];
|
||||||
while(!should_quit){
|
while(!should_quit){
|
||||||
fgets(buffer, 2048, stdin);
|
fgets(buffer, 2048, stdin);
|
||||||
@ -61,8 +61,8 @@ int main(){
|
|||||||
fprintf(stderr, "Succ\n");
|
fprintf(stderr, "Succ\n");
|
||||||
|
|
||||||
std::atomic_bool should_quit = false;
|
std::atomic_bool should_quit = false;
|
||||||
std::thread sync_thread(sync_fn, std::ref(ses.get_syncer()), std::ref(should_quit));
|
std::thread sync_thread(sync_fn, ses.create_syncer(), std::ref(should_quit));
|
||||||
std::thread key_thread(keyboard_fn, std::ref(ses.get_client()), std::ref(should_quit));
|
std::thread key_thread(keyboard_fn, ses.create_client(), std::ref(should_quit));
|
||||||
|
|
||||||
//one of these threads will always hang until another input is recieved
|
//one of these threads will always hang until another input is recieved
|
||||||
sync_thread.join();
|
sync_thread.join();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user