HISE Logo Forum
    • Categories
    • Register
    • Login

    Displaying notification from my server via API

    Scheduled Pinned Locked Moved General Questions
    3 Posts 2 Posters 193 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • gorangroovesG
      gorangrooves
      last edited by

      I have a script that checks my server and reads a js file via API for the latest version. If a newer version if found, it is supposed to display a notification button, which when clicked displays a panel with text pulled from the server.

      In the console, I can see that the API is working correctly and the response is correct. It shows all the data from the js file.
      However, I am doing something wrong here, as I am getting an error and the button won't show.

      Here is what I have onInit:

      //-----------Notifications based on current version number-------
      
      const var VersionLabel = Content.getComponent("VersionLabel");
      reg versionNumber= Engine.getVersion(); //pull the current version# from the software
      VersionLabel.set("text", "v "+versionNumber); //display the current version on the interface
      
      reg vn= versionNumber.split('.'); //Turn the current version number into an array;
      
      const var p = {
          "request": "version"
      };
      
      reg an;
      reg NotificationURL;
      Server.setBaseURL("https://subdomain.mywebsite.com");
      Server.callWithGET("/world_percussion_version", p, function(status, response)
      {
           Synth.startTimer(10);
           an = response;
           Console.print(trace(response));
      });
      const var NotificationMessage = Content.getComponent("NotificationMessage");
      const var NotificationTitle = Content.getComponent("NotificationTitle");
      

      The problem is onTimer:

      function onTimer()
      {
      	if(isDefined(an)){
              Synth.stopTimer();
              Console.print("Timer stopped");
              //Setting variables from server information
              
              NotificationMessage.set("text", an["NotificationMessage"]);
              
              NotificationTitle.set("text", an["NotificationTitle"]);
              NotificationURL = an["NotificationURL"];
              var newVersion = an["version"].split('.');
              
              //Comparing versions
             if (newVersion[0] > vn[0] || (newVersion[0] == vn[0] && newVersion[1] > vn[1]) || (newVersion[0] == vn[0] && newVersion[1] == vn[1] && newVersion[2] > vn[2])){
                  UpdateButton.showControl(true); 
             }
          }
      }
       
      

      I receive the following error

      Interface:! onTimer() - Line 8, column 32: Illegal operation in audio thread: HeapBlock allocation
      

      What am I missing/doing wrong here?

      I should note that a developer I hired, made this work, but that she was using a standalone HISE through Visual Studio. It is not working for me using the plugin version of HISE (latest Scriptnode).

      Thank you!

      Goran Rista
      https://gorangrooves.com

      Handy Drums and Handy Grooves
      https://library.gorangrooves.com

      1 Reply Last reply Reply Quote 0
      • Christoph HartC
        Christoph Hart
        last edited by

        1. Don't use the inbuilt timer callback, it's for real-time event processing.
        2. Why do you use a timer at all? Just put the logic into the server callback.
        gorangroovesG 1 Reply Last reply Reply Quote 0
        • gorangroovesG
          gorangrooves @Christoph Hart
          last edited by

          @Christoph-Hart Thank you so much! I can't believe that I actually made it work just by following your advice :) Seems like I am beginning to understand things. Thank you so much 🤜 🤛

          Goran Rista
          https://gorangrooves.com

          Handy Drums and Handy Grooves
          https://library.gorangrooves.com

          1 Reply Last reply Reply Quote 1
          • First post
            Last post

          18

          Online

          1.7k

          Users

          11.8k

          Topics

          102.5k

          Posts