|
@@ -12,9 +12,9 @@
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
|
-NetworkConnection::NetworkConnection(INetworkConnectionListener & listener, const std::shared_ptr<NetworkSocket> & socket, const std::shared_ptr<NetworkContext> & context)
|
|
|
+NetworkConnection::NetworkConnection(INetworkConnectionListener & listener, const std::shared_ptr<NetworkSocket> & socket, NetworkContext & context)
|
|
|
: socket(socket)
|
|
|
- , timer(std::make_shared<NetworkTimer>(*context))
|
|
|
+ , timer(std::make_shared<NetworkTimer>(context))
|
|
|
, listener(listener)
|
|
|
{
|
|
|
socket->set_option(boost::asio::ip::tcp::no_delay(true));
|
|
@@ -208,7 +208,7 @@ void NetworkConnection::close()
|
|
|
//NOTE: ignoring error code, intended
|
|
|
}
|
|
|
|
|
|
-InternalConnection::InternalConnection(INetworkConnectionListener & listener, const std::shared_ptr<NetworkContext> & context)
|
|
|
+InternalConnection::InternalConnection(INetworkConnectionListener & listener, NetworkContext & context)
|
|
|
: io(context)
|
|
|
, listener(listener)
|
|
|
{
|
|
@@ -216,7 +216,7 @@ InternalConnection::InternalConnection(INetworkConnectionListener & listener, co
|
|
|
|
|
|
void InternalConnection::receivePacket(const std::vector<std::byte> & message)
|
|
|
{
|
|
|
- boost::asio::post(*io, [self = std::static_pointer_cast<InternalConnection>(shared_from_this()), message](){
|
|
|
+ boost::asio::post(io, [self = std::static_pointer_cast<InternalConnection>(shared_from_this()), message](){
|
|
|
if (self->connectionActive)
|
|
|
self->listener.onPacketReceived(self, message);
|
|
|
});
|
|
@@ -224,7 +224,7 @@ void InternalConnection::receivePacket(const std::vector<std::byte> & message)
|
|
|
|
|
|
void InternalConnection::disconnect()
|
|
|
{
|
|
|
- boost::asio::post(*io, [self = std::static_pointer_cast<InternalConnection>(shared_from_this())](){
|
|
|
+ boost::asio::post(io, [self = std::static_pointer_cast<InternalConnection>(shared_from_this())](){
|
|
|
self->listener.onDisconnected(self, "Internal connection has been terminated");
|
|
|
self->otherSideWeak.reset();
|
|
|
self->connectionActive = false;
|