File tree Expand file tree Collapse file tree 3 files changed +12
-4
lines changed
Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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});
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ <h1>I am served</h1>
1313// the cpp back end will send us messages
1414function 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
You can’t perform that action at this time.
0 commit comments