ClientCache
This commit is contained in:
@@ -243,9 +243,18 @@ coro<> GameServer::pushSocketGameProtocol(tcp::socket socket, const std::string
|
||||
lock.unlock();
|
||||
|
||||
co_await Net::AsyncSocket::write<uint8_t>(socket, 0);
|
||||
// Считываем ресурсы хранимые в кеше клиента
|
||||
uint32_t count = co_await Net::AsyncSocket::read<uint32_t>(socket);
|
||||
if(count > 262144)
|
||||
MAKE_ERROR("Не поддерживаемое количество ресурсов в кеше у клиента");
|
||||
|
||||
std::vector<HASH> clientCache;
|
||||
clientCache.resize(count);
|
||||
co_await Net::AsyncSocket::read(socket, (std::byte*) clientCache.data(), count*32);
|
||||
std::sort(clientCache.begin(), clientCache.end());
|
||||
|
||||
External.NewConnectedPlayers.lock_write()
|
||||
->push_back(std::make_unique<RemoteClient>(IOC, std::move(socket), username));
|
||||
->push_back(std::make_unique<RemoteClient>(IOC, std::move(socket), username, std::move(clientCache)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <unordered_set>
|
||||
|
||||
namespace LV::Server {
|
||||
using HASH = std::array<uint8_t, 32>;
|
||||
|
||||
template<typename ServerKey, typename ClientKey, std::enable_if_t<sizeof(ServerKey) >= sizeof(ClientKey), int> = 0>
|
||||
class CSChunkedMapper {
|
||||
@@ -185,6 +186,7 @@ class RemoteClient {
|
||||
DestroyLock UseLock;
|
||||
Net::AsyncSocket Socket;
|
||||
bool IsConnected = true, IsGoingShutdown = false;
|
||||
std::vector<HASH> ClientCache;
|
||||
|
||||
struct ResUsesObj {
|
||||
// Счётчики использования базовых ресурсов высшими объектами
|
||||
@@ -270,8 +272,8 @@ public:
|
||||
ToServer::PacketQuat CameraQuat = {0};
|
||||
|
||||
public:
|
||||
RemoteClient(asio::io_context &ioc, tcp::socket socket, const std::string username)
|
||||
: LOG("RemoteClient " + username), Socket(ioc, std::move(socket)), Username(username)
|
||||
RemoteClient(asio::io_context &ioc, tcp::socket socket, const std::string username, std::vector<HASH> &&client_cache)
|
||||
: LOG("RemoteClient " + username), Socket(ioc, std::move(socket)), Username(username), ClientCache(std::move(client_cache))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user