parent
37f21d8167
commit
3a6f7e7d7d
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
#include "DirtySockServer.hpp"
|
#include "DirtySockServer.hpp"
|
||||||
|
|
||||||
|
constexpr static auto MAX_PAYLOAD_SIZE = 4 * (1024 * 1024);
|
||||||
|
|
||||||
namespace ls {
|
namespace ls {
|
||||||
|
|
||||||
DirtySockClient::DirtySockClient(Stream stream, base::Ref<DirtySockServer> server)
|
DirtySockClient::DirtySockClient(Stream stream, base::Ref<DirtySockServer> server)
|
||||||
|
@ -26,6 +28,12 @@ namespace ls {
|
||||||
try {
|
try {
|
||||||
co_await asio::async_read(stream, asio::buffer(&header, sizeof(header)), asio::deferred);
|
co_await asio::async_read(stream, asio::buffer(&header, sizeof(header)), asio::deferred);
|
||||||
|
|
||||||
|
// Sanity check. I don't expect game payloa
|
||||||
|
if(header.payloadSize > MAX_PAYLOAD_SIZE) {
|
||||||
|
base::LogError("WOAH! Message size {} MB larger than {}MB..", (static_cast<float>(header.payloadSize) / 1024 / 1024), (static_cast<float>(MAX_PAYLOAD_SIZE) / 1024 / 1024));
|
||||||
|
co_return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
propertyBuffer.resize(header.payloadSize);
|
propertyBuffer.resize(header.payloadSize);
|
||||||
|
|
||||||
co_await asio::async_read(stream, asio::buffer(propertyBuffer), asio::deferred);
|
co_await asio::async_read(stream, asio::buffer(propertyBuffer), asio::deferred);
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#include <base/logger.hpp>
|
#include <base/logger.hpp>
|
||||||
#include <impl/asio_config.hpp>
|
#include <impl/asio_config.hpp>
|
||||||
|
|
||||||
|
// So debug message can just reply
|
||||||
|
#include "DirtySockClient.hpp"
|
||||||
#include "WireMessage.hpp"
|
#include "WireMessage.hpp"
|
||||||
|
|
||||||
namespace ls {
|
namespace ls {
|
||||||
|
@ -156,6 +158,9 @@ namespace ls {
|
||||||
|
|
||||||
for(auto [key, value] : properties)
|
for(auto [key, value] : properties)
|
||||||
base::LogInfo("{}: {}", key, value);
|
base::LogInfo("{}: {}", key, value);
|
||||||
|
|
||||||
|
// :( but it works to just replay the message.
|
||||||
|
co_await client->WriteMessage(std::make_shared<DebugMessage>(*this));
|
||||||
co_return;
|
co_return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -174,7 +179,7 @@ namespace ls {
|
||||||
else
|
else
|
||||||
ret = std::make_shared<DebugMessage>(header);
|
ret = std::make_shared<DebugMessage>(header);
|
||||||
|
|
||||||
if(ret->ParseFromInputBuffer(propertyDataBuffer))
|
if(!ret->ParseFromInputBuffer(propertyDataBuffer))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue