Skip to content

Commit a8a7937

Browse files
author
MYK
committed
adding callback removed assert fail
1 parent 0379cb1 commit a8a7937

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ The embedded web server is the header-only cpp-httplib by Yuji Hirose from here:
2525
# TODO
2626

2727
* [DONE] web interface -> cpp comms
28-
* [DONE except annoying assert] cpp -> web interface comms
28+
* [DONE] cpp -> web interface comms
2929
* test on mac and windows

src/PluginEditor.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,16 @@ void PluginEditor::updateUIFromProcessor(const juce::String& msg)
5252
obj->setProperty("msg", msg);
5353
juce::var data(obj);
5454
juce::String json = juce::JSON::toString(data);
55-
56-
webView.evaluateJavascript("handleCppMessage(" + json + ");", nullptr);
55+
// eval some javascript in the webui which causes it to call
56+
// a function called handleCppMessage with the data
57+
webView.evaluateJavascript("handleCppMessage(" + json + ");",
58+
[](juce::WebBrowserComponent::EvaluationResult result) {
59+
std::cout << "PluginEditor::updateUIFromProcessor js eval completed with res : " << result.getResult() << std::endl;
60+
// code to run once the javascript has been evaluated ...
61+
// e.g. maybe re-enable the animation loop if you are waiting
62+
// for a UI update
63+
}
64+
);
5765

5866
// std::string msg_as_json = "{\"msg\":\""+ msg + "\"}";
5967
// juce::JSON::toString({"msg":msg});

src/ui/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ <h1>I am served</h1>
1313
// the cpp back end will send us messages
1414
function handleCppMessage(data){
1515
// data = JSON.parse(json_string);
16-
console.log(data["msg"])
16+
console.log("javascript function handleCppMessage received some data: " + data["msg"])
1717
msg_div = document.getElementById("messages");
1818
msg_div.innerText = data.msg;
1919

0 commit comments

Comments
 (0)