#include "Speckle/Interface/Browser/Bridge/Functions/GetCallResult.h" #include "Active/Serialise/Item/Wrapper/ItemWrap.h" #include "Active/Serialise/JSON/JSONTransport.h" #include "Active/Utility/BufferOut.h" #include "Speckle/Interface/Browser/Bridge/BrowserBridge.h" #include #ifdef ARCHICAD #include #include #endif using namespace active::serialise; using namespace speckle::serialise::jsbase; using namespace speckle::interfac::browser; using namespace speckle::interfac::browser::bridge; using namespace speckle::utility; /*-------------------------------------------------------------------- Constructor bridge: The parent bridge object (provides access to bridge methods) --------------------------------------------------------------------*/ GetCallResult::GetCallResult(BrowserBridge& bridge) : m_bridge{bridge}, JSFunction{"GetCallResult", [&](auto args) { return getResult(args); }} { } //GetCallResult::GetCallResult /*-------------------------------------------------------------------- Get the result for a specified call argument: The method arguments specifying the target bridge and requestID return: The requested result (nullptr on failure) --------------------------------------------------------------------*/ std::unique_ptr GetCallResult::getResult(WrappedResultArg& argument) const { //Retrieve the requested result using namespace json; auto result = m_bridge.releaseResult(argument); auto item = dynamic_cast(result.get()); if (!item) return nullptr; String jsonOutput; JSONTransport().send(std::forward(*item), Identity{}, jsonOutput); return std::make_unique(jsonOutput); } //GetCallResult::getResult