Server.setBaseURL
-
I am trying to set the URL for server communication. I thought I would be able to use it in the onInit of a Script FX module but it is giving an error saying Unknown function 'setBaseURL'. How can I use this function?
-
-
@TNTHM It's for use in midi processors. I don't think it will work in a script effect
-
@d-healey yup most of the UI related classes are not present in anything else than the Script MidiProcessor.
-
Is it possible to communicate with a server through the plugin? I have set up a server at http://localhost:3000 and I am trying to send data to it when a button on the GUI is clicked. In the code below, which is in the onInit of the Interface, 4 and 5 print but 6 does not. Is there a way to have the plugin communicate with a server?
inline function onButton1Control(number, value) { Console.print("4"); // if the button was clicked if (value == 1) { Console.print("5"); // Send data to the server and wait for the response Server.callWithPOST("http://localhost:3000", data, function(status, response) { Console.print("6"); // HTTP status 200 means the request was successful if (status == 200) { // print a success message to the HISE console Console.print("Successfully sent data to the server"); } else { Console.print("Error occurred while contacting the server: " + status); } }); } }
-
@TNTHM For testing with a local server you'll need to use the IP address. Have you declared
data
? -
@d-healey I did declare data. And I confirmed that the server is running on port 3000 through terminal. When I replaced localhost with my computer's IP address it still does not print 6.
Content.makeFrontInterface(600, 600); Console.print("1"); const var Button1 = Content.getComponent("Button1"); Console.print("2"); var data = { message: "Hello world!" }; Console.print("3"); inline function onButton1Control(number, value) { Console.print("4"); // if the button was clicked if (value == 1) { Console.print("5"); // Send data to the server and wait for the response Server.callWithPOST("http://localhost:3000", data, function(status, response) { Console.print("6"); if (status == 200) // HTTP status 200 means the request was successful { // print a success message to the HISE console Console.print("Successfully sent data to the server"); } else { Console.print("Error occurred while contacting the server: " + status); } }); } } Button1.setControlCallback(onButton1Control);
-
@TNTHM You haven't called
Server.setBaseURL()
Check out all the server documentation - https://docs.hise.audio/scripting/scripting-api/server/index.html
-
@d-healey This was what I was missing. Thank you!