Mercurial > hg > orthanc-stone
view Platforms/Wasm/WasmPlatformApplicationAdapter.cpp @ 311:3b29c9c77d9b am-callable-and-promise
Close branch am-callable-and-promise
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 02 Oct 2018 10:15:36 +0200 |
parents | be2660b6e40a |
children | daa04d15192c |
line wrap: on
line source
#include "WasmPlatformApplicationAdapter.h" #include "Framework/Toolbox/MessagingToolbox.h" #include "Framework/StoneException.h" #include <Applications/Commands/BaseCommandBuilder.h> #include <stdio.h> #include "Platforms/Wasm/Defaults.h" namespace OrthancStone { WasmPlatformApplicationAdapter::WasmPlatformApplicationAdapter(MessageBroker& broker, IStoneApplication& application) : IObserver(broker), application_(application) { } void WasmPlatformApplicationAdapter::HandleMessageFromWeb(std::string& output, const std::string& input) { try { Json::Value inputJson; if (MessagingToolbox::ParseJson(inputJson, input.c_str(), input.size())) { std::unique_ptr<ICommand> command(application_.GetCommandBuilder().CreateFromJson(inputJson)); application_.ExecuteCommand(*command); } } catch (StoneException& exc) { printf("Error while handling message from web (error code = %d):\n", exc.GetErrorCode()); printf("While interpreting input: '%s'\n", input.c_str()); } } void WasmPlatformApplicationAdapter::NotifyStatusUpdateFromCppToWeb(const std::string& statusUpdateMessage) { printf("NotifyStatusUpdateFromCppToWeb (TODO)\n"); UpdateStoneApplicationStatusFromCpp(statusUpdateMessage.c_str()); printf("NotifyStatusUpdateFromCppToWeb (DONE)\n"); } }