diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index 3a8e6e6ea8e..db08229a36f 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -917,9 +917,14 @@ void ProtocolGame::disconnectClient(const std::string &message) const { } void ProtocolGame::writeToOutputBuffer(NetworkMessage &msg) { - g_dispatcher().safeCall([self = getThis(), msg = std::move(msg)] { - self->getOutputBuffer(msg.getLength())->append(msg); - }); + if (g_dispatcher().context().isAsync()) { + g_dispatcher().addEvent([self = getThis(), msg] { + self->getOutputBuffer(msg.getLength())->append(msg); + }, + __FUNCTION__); + } else { + getOutputBuffer(msg.getLength())->append(msg); + } } void ProtocolGame::parsePacket(NetworkMessage &msg) {