debug, deleting assets
This commit is contained in:
parent
19d786631a
commit
a2c2c2a883
20 changed files with 139 additions and 21 deletions
|
@ -14,6 +14,7 @@
|
|||
#include "handler/poll.h"
|
||||
#include "handler/listassets.h"
|
||||
#include "handler/addasset.h"
|
||||
#include "handler/deleteasset.h"
|
||||
|
||||
#include "taskmanager/route.h"
|
||||
|
||||
|
@ -71,6 +72,7 @@ void Server::run (int socketDescriptor) {
|
|||
router->addRoute(std::make_unique<Handler::Poll>(shared_from_this()));
|
||||
router->addRoute(std::make_unique<Handler::ListAssets>(shared_from_this()));
|
||||
router->addRoute(std::make_unique<Handler::AddAsset>(shared_from_this()));
|
||||
router->addRoute(std::make_unique<Handler::DeleteAsset>(shared_from_this()));
|
||||
|
||||
taskManager->start();
|
||||
scheduler->start();
|
||||
|
|
|
@ -101,7 +101,7 @@ void Session::onTimeout () {
|
|||
|
||||
void Session::assetAdded (const DB::Asset& asset) {
|
||||
std::lock_guard lock(mtx);
|
||||
auto assets = cache["assets"];
|
||||
std::map<std::string, nlohmann::json>& assets = cache["assets"];
|
||||
auto addedItr = assets.find("added");
|
||||
if (addedItr == assets.end())
|
||||
addedItr = assets.emplace("added", nlohmann::json::array()).first;
|
||||
|
@ -110,6 +110,17 @@ void Session::assetAdded (const DB::Asset& asset) {
|
|||
checkUpdates();
|
||||
}
|
||||
|
||||
void Session::assetRemoved (unsigned int assetId) {
|
||||
std::lock_guard lock(mtx);
|
||||
std::map<std::string, nlohmann::json>& assets = cache["assets"];
|
||||
auto addedItr = assets.find("removed");
|
||||
if (addedItr == assets.end())
|
||||
addedItr = assets.emplace("removed", nlohmann::json::array()).first;
|
||||
|
||||
addedItr->second.push_back(assetId);
|
||||
checkUpdates();
|
||||
}
|
||||
|
||||
void Session::checkUpdates () {
|
||||
std::shared_ptr<TM::Scheduler> sch = scheduler.lock();
|
||||
if (polling) {
|
||||
|
|
|
@ -38,6 +38,7 @@ public:
|
|||
const unsigned int owner;
|
||||
|
||||
void assetAdded (const DB::Asset& asset);
|
||||
void assetRemoved (unsigned int assetId);
|
||||
|
||||
private:
|
||||
void onTimeout ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue