Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/lib/util/client_ws.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ namespace webpp {
std::list<SendData> send_queue;

void send_from_queue() {
strand.post([this]() {
asio::post(strand, [this]() {
asio::async_write(*socket, send_queue.begin()->send_stream->streambuf,
strand.wrap([this](const std::error_code& ec, size_t /*bytes_transferred*/) {
auto send_queued=send_queue.begin();
Expand Down Expand Up @@ -175,7 +175,7 @@ namespace webpp {
}

if(io_context->stopped())
io_context->reset();
io_context->restart();

if(!resolver)
resolver= std::make_unique<asio::ip::tcp::resolver>(*io_context);
Expand Down Expand Up @@ -237,7 +237,7 @@ namespace webpp {
send_stream->put(message_stream->get()^mask[c%4]);
}

connection->strand.post([this, send_stream, callback]() {
asio::post(connection->strand, [this, send_stream, callback]() {
connection->send_queue.emplace_back(send_stream, callback);
if(connection->send_queue.size()==1)
connection->send_from_queue();
Expand Down Expand Up @@ -516,18 +516,18 @@ namespace webpp {

protected:
void connect() override {
asio::ip::tcp::resolver::query query(host, std::to_string(port));

resolver->async_resolve(query, [this]
(const std::error_code &ec, asio::ip::tcp::resolver::iterator it){
resolver->async_resolve(host, std::to_string(port), [this]
(const std::error_code &ec, asio::ip::tcp::resolver::results_type results){
if(!ec) {
connection=std::shared_ptr<Connection>(new Connection(*io_context, new WS(*io_context)));
if (!this->connection) {
this->connection = std::shared_ptr<Connection>(new Connection(*io_context, new WS(*io_context)));
}

asio::async_connect(*connection->socket, it, [this]
(const std::error_code &ec, asio::ip::tcp::resolver::iterator /*it*/){
asio::async_connect(*this->connection->socket, results, [this]
(const std::error_code &ec, const asio::ip::tcp::endpoint &) {
if(!ec) {
asio::ip::tcp::no_delay option(true);
connection->socket->set_option(option);
this->connection->socket->set_option(option);

handshake();
}
Expand Down
12 changes: 6 additions & 6 deletions src/lib/util/server_ws_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ namespace webpp {
std::list<SendData> send_queue;

void send_from_queue(const std::shared_ptr<Connection> &connection) {
strand.post([this, connection]() {
asio::post(strand, [this, connection]() {
asio::async_write(*socket, send_queue.begin()->header_stream->streambuf,
strand.wrap([this, connection](const std::error_code& ec, size_t /*bytes_transferred*/) {
if(!ec) {
Expand Down Expand Up @@ -219,11 +219,11 @@ namespace webpp {
io_context=std::make_shared<asio::io_context>();

if(io_context->stopped())
io_context->reset();
io_context->restart();

asio::ip::tcp::endpoint endpoint;
if(config.address.size()>0)
endpoint=asio::ip::tcp::endpoint(asio::ip::address::from_string(config.address), config.port);
endpoint=asio::ip::tcp::endpoint(asio::ip::make_address(config.address), config.port);
else
endpoint=asio::ip::tcp::endpoint(asio::ip::tcp::v4(), config.port);

Expand Down Expand Up @@ -283,7 +283,7 @@ namespace webpp {
else
header_stream->put(static_cast<unsigned char>(length));

connection->strand.post([connection, header_stream, message_stream, callback]() {
asio::post(connection->strand, [connection, header_stream, message_stream, callback]() {
connection->send_queue.emplace_back(header_stream, message_stream, callback);
if(connection->send_queue.size()==1)
connection->send_from_queue(connection);
Expand Down Expand Up @@ -653,12 +653,12 @@ namespace webpp {
void timer_idle_init(const std::shared_ptr<Connection> &connection) {
if(config.timeout_idle>0) {
connection->timer_idle= std::make_unique<asio::system_timer>(connection->socket->get_executor());
connection->timer_idle->expires_from_now(std::chrono::seconds(static_cast<unsigned long>(config.timeout_idle)));
connection->timer_idle->expires_after(std::chrono::seconds(static_cast<unsigned long>(config.timeout_idle)));
timer_idle_expired_function(connection);
}
}
void timer_idle_reset(const std::shared_ptr<Connection> &connection) const {
if(config.timeout_idle>0 && connection->timer_idle->expires_from_now(std::chrono::seconds(static_cast<unsigned long>(config.timeout_idle)))>0)
if(config.timeout_idle>0 && connection->timer_idle->expires_after(std::chrono::seconds(static_cast<unsigned long>(config.timeout_idle)))>0)
timer_idle_expired_function(connection);
}
void timer_idle_cancel(const std::shared_ptr<Connection> &connection) const {
Expand Down
8 changes: 4 additions & 4 deletions src/mame/capcom/cps2comm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class cps2_comm_device::context

void stop()
{
m_ioctx.post(
asio::post(m_ioctx.get_executor(),
[this] ()
{
m_stopping = true;
Expand All @@ -191,7 +191,7 @@ class cps2_comm_device::context

void set_routing(u8 val)
{
m_ioctx.post(
asio::post(m_ioctx.get_executor(),
[this, val] ()
{
if (BIT(val, 0, 2) == 0U)
Expand All @@ -216,7 +216,7 @@ class cps2_comm_device::context

void send_in(u8 data)
{
m_ioctx.post(
asio::post(m_ioctx.get_executor(),
[this, data] ()
{
if (m_in_connected)
Expand All @@ -231,7 +231,7 @@ class cps2_comm_device::context

void send_out(u8 data)
{
m_ioctx.post(
asio::post(m_ioctx.get_executor(),
[this, data] ()
{
if (m_out_sock.is_open())
Expand Down
Loading