Mercurial > hg > orthanc-stone
comparison Platforms/Wasm/WasmPlatformApplicationAdapter.cpp @ 319:daa04d15192c am-2
new SimpleViewer sample that has been split in multiple files to be able to scale it
author | am@osimis.io |
---|---|
date | Thu, 11 Oct 2018 13:16:54 +0200 |
parents | be2660b6e40a |
children | a902a07769d4 |
comparison
equal
deleted
inserted
replaced
318:3a4ca166fafa | 319:daa04d15192c |
---|---|
17 void WasmPlatformApplicationAdapter::HandleMessageFromWeb(std::string& output, const std::string& input) | 17 void WasmPlatformApplicationAdapter::HandleMessageFromWeb(std::string& output, const std::string& input) |
18 { | 18 { |
19 try | 19 try |
20 { | 20 { |
21 Json::Value inputJson; | 21 Json::Value inputJson; |
22 // if the message is a command, build it and execute it | |
22 if (MessagingToolbox::ParseJson(inputJson, input.c_str(), input.size())) | 23 if (MessagingToolbox::ParseJson(inputJson, input.c_str(), input.size())) |
23 { | 24 { |
24 std::unique_ptr<ICommand> command(application_.GetCommandBuilder().CreateFromJson(inputJson)); | 25 std::unique_ptr<ICommand> command(application_.GetCommandBuilder().CreateFromJson(inputJson)); |
25 application_.ExecuteCommand(*command); | 26 if (command.get() == NULL) |
27 printf("Could not parse command: '%s'\n", input.c_str()); | |
28 else | |
29 application_.ExecuteCommand(*command); | |
26 } | 30 } |
27 } | 31 } |
28 catch (StoneException& exc) | 32 catch (StoneException& exc) |
29 { | 33 { |
30 printf("Error while handling message from web (error code = %d):\n", exc.GetErrorCode()); | 34 printf("Error while handling message from web (error code = %d):\n", exc.GetErrorCode()); |