Mercurial > hg > orthanc-stone
comparison Platforms/Wasm/WasmPlatformApplicationAdapter.cpp @ 307:be2660b6e40a am-callable-and-promise
wip: commands + status update
author | am@osimis.io |
---|---|
date | Tue, 25 Sep 2018 15:14:53 +0200 |
parents | |
children | daa04d15192c |
comparison
equal
deleted
inserted
replaced
304:6c22e0506587 | 307:be2660b6e40a |
---|---|
1 #include "WasmPlatformApplicationAdapter.h" | |
2 | |
3 #include "Framework/Toolbox/MessagingToolbox.h" | |
4 #include "Framework/StoneException.h" | |
5 #include <Applications/Commands/BaseCommandBuilder.h> | |
6 #include <stdio.h> | |
7 #include "Platforms/Wasm/Defaults.h" | |
8 | |
9 namespace OrthancStone | |
10 { | |
11 WasmPlatformApplicationAdapter::WasmPlatformApplicationAdapter(MessageBroker& broker, IStoneApplication& application) | |
12 : IObserver(broker), | |
13 application_(application) | |
14 { | |
15 } | |
16 | |
17 void WasmPlatformApplicationAdapter::HandleMessageFromWeb(std::string& output, const std::string& input) | |
18 { | |
19 try | |
20 { | |
21 Json::Value inputJson; | |
22 if (MessagingToolbox::ParseJson(inputJson, input.c_str(), input.size())) | |
23 { | |
24 std::unique_ptr<ICommand> command(application_.GetCommandBuilder().CreateFromJson(inputJson)); | |
25 application_.ExecuteCommand(*command); | |
26 } | |
27 } | |
28 catch (StoneException& exc) | |
29 { | |
30 printf("Error while handling message from web (error code = %d):\n", exc.GetErrorCode()); | |
31 printf("While interpreting input: '%s'\n", input.c_str()); | |
32 } | |
33 } | |
34 | |
35 void WasmPlatformApplicationAdapter::NotifyStatusUpdateFromCppToWeb(const std::string& statusUpdateMessage) | |
36 { | |
37 printf("NotifyStatusUpdateFromCppToWeb (TODO)\n"); | |
38 UpdateStoneApplicationStatusFromCpp(statusUpdateMessage.c_str()); | |
39 printf("NotifyStatusUpdateFromCppToWeb (DONE)\n"); | |
40 } | |
41 | |
42 } |