Mercurial > hg > orthanc-stone
diff Platforms/Wasm/Defaults.cpp @ 508:7105a0bad250 bgo-commands-codegen
- Added HandleSerializedMessage to IStoneApplication (empty impl)
- Split UpdateWebApplication with "WithString" and "WithSerializedMessage" variants
- Due to the modules in TS, globals are now unallowed and the callbacks from C++ to JS are stored in the "window" instance
- Split UpdateStoneApplicationStatusFromCpp with "WithString" and "WithSerializedMessage" variants
- Split NotifyStatusUpdateFromCppToWeb with "WithString" and "WithSerializedMessage" variants
- SendMessageToStoneApplication (C++ global) has been split into SendSerializedMessageToStoneApplication and SendCommandToStoneApplication
- In WasmPlatformApplicationAdapter: HandleMessageFromWeb becomes HandleCommandFromWeb
- In WasmPlatformApplicationAdapter: added HandleSerializedMessageFromWeb
- stonegentool now handles the "json" primitive type (used, a.o., in the VSOL "EditInstance" message)
- Fixed indentation and added json serialization overloads in the stonegentool templates
- Added test of the json primitive type to testWasmIntegrated (in Resources/CodeGeneration)
- Adapted testWasmIntegrated (in Resources/CodeGeneration) to the changes above
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Wed, 06 Mar 2019 10:14:59 +0100 |
parents | e74f9271d653 |
children | 97a16b694321 |
line wrap: on
line diff
--- a/Platforms/Wasm/Defaults.cpp Fri Mar 01 16:18:38 2019 +0100 +++ b/Platforms/Wasm/Defaults.cpp Wed Mar 06 10:14:59 2019 +0100 @@ -342,20 +342,37 @@ viewport->MouseLeave(); } - const char* EMSCRIPTEN_KEEPALIVE SendMessageToStoneApplication(const char* message) + const char* EMSCRIPTEN_KEEPALIVE SendSerializedMessageToStoneApplication(const char* message) { static std::string output; // we don't want the string to be deallocated when we return to JS code so we always use the same string (this is fine since JS is single-thread) - printf("SendMessageToStoneApplication (JS -> C++): %s\n", message); + printf("SendSerializedMessageToStoneApplication\n"); + printf("%s", message); if (applicationWasmAdapter.get() != NULL) { - applicationWasmAdapter->HandleMessageFromWeb(output, std::string(message)); + printf("sending serialized message to C++\n"); + applicationWasmAdapter->HandleSerializedMessageFromWeb(output, std::string(message)); return output.c_str(); } - printf("This stone application does not have a Web Adapter\n"); + printf("This Stone application does not have a Web Adapter"); return NULL; } + const char* EMSCRIPTEN_KEEPALIVE SendCommandToStoneApplication(const char* message) + { + static std::string output; // we don't want the string to be deallocated when we return to JS code so we always use the same string (this is fine since JS is single-thread) + + printf("SendCommandToStoneApplication\n"); + printf("%s", message); + + if (applicationWasmAdapter.get() != NULL) { + printf("sending command to C++\n"); + applicationWasmAdapter->HandleCommandFromWeb(output, std::string(message)); + return output.c_str(); + } + printf("This Stone application does not have a Web Adapter"); + return NULL; + } #ifdef __cplusplus }