Home of the Squeezebox™ & Transporter® network music players.
Results 1 to 8 of 8
  1. #1
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    3,241

    Refreshing a setting page in callback

    Hi - How can I force refresh of a page (a plugin setting page) when I receive a callback from something else (in that case an HTTP request)
    LMS 7.7, 7.8 and 7.9 - 5xRadio, 3xBoom, 4xDuet, 1xTouch, 1 SB2. Sonos PLAY:3, PLAY:5, Marantz NR1603, JBL OnBeat, XBoxOne, XBMC, Foobar2000, ShairPortW, JRiver 21, 2xChromecast Audio, Chromecast v1 and v2, , Pi B3, B2, Pi B+, 2xPi A+, Odroid-C1, Odroid-C2, Cubie2, Yamaha WX-010, AppleTV 4, Airport Express

  2. #2
    Senior Member meep's Avatar
    Join Date
    Aug 2007
    Location
    Ireland
    Posts
    208
    I've posted code in this thread to do something similar;

    http://forums.slimdevices.com/showth...I-How-to/page3

    In my case, I trigger a http request from inside the settings page, display an animation as I await the response and then update the page with information based on the response.

    The whole thread is actually about this and the code I've posted just shows how I implemented it.
    Last edited by meep; 2017-01-28 at 02:42.


    ALEXA LMS SKILL: http://www.hab-tunes.com | Twitter: #habtunes
    Personal HA BLOG: http://mediaserver8.blogspot.com

    Squeezebox | Squeezebox Radio x 2 | Squeezebox Duet

  3. #3
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    3,241
    Quote Originally Posted by meep View Post
    I've posted code in this thread to do something similar;

    http://forums.slimdevices.com/showth...I-How-to/page3

    In my case, I trigger a http request from inside the settings page, display an animation as I await the response and then update the page with information based on the response.

    The whole thread is actually about this and the code I've posted just shows how I implemented it.
    Thanks but I'm still confused. I don't need to add anything that would be available on the CLI, I just want to have the settings page refresh and its handler called. I realize that what you do is similar, I'm just lost why it implies adding a dispatch on the CLI.
    LMS 7.7, 7.8 and 7.9 - 5xRadio, 3xBoom, 4xDuet, 1xTouch, 1 SB2. Sonos PLAY:3, PLAY:5, Marantz NR1603, JBL OnBeat, XBoxOne, XBMC, Foobar2000, ShairPortW, JRiver 21, 2xChromecast Audio, Chromecast v1 and v2, , Pi B3, B2, Pi B+, 2xPi A+, Odroid-C1, Odroid-C2, Cubie2, Yamaha WX-010, AppleTV 4, Airport Express

  4. #4
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    19,757

    Refreshing a setting page in callback

    > Thanks but I'm still confused. I don't need to add anything that would
    > be available on the CLI, I just want to have the settings page refresh
    > and its handler called. I realize that what you do is similar, I'm just
    > lost why it implies adding a dispatch on the CLI.


    Good old http is a pull protocol. The server can't push to the client.
    Therefore it can't refresh the page when the server is done.

    One approach to overcome this limitation is to poll the server for its
    status. Some JavaScript would send a request to the server in intervals,
    then trigger the refresh when the server reported "done".

    This polling can be done using a traditional web page handler, or
    potentially lighter using a custom CLI command called over json/rpc. You
    don't have to use a CLI command. A regular web page handler could be
    good enough.

    --

    Michael

  5. #5
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    3,241
    Quote Originally Posted by mherger View Post
    > Thanks but I'm still confused. I don't need to add anything that would
    > be available on the CLI, I just want to have the settings page refresh
    > and its handler called. I realize that what you do is similar, I'm just
    > lost why it implies adding a dispatch on the CLI.


    Good old http is a pull protocol. The server can't push to the client.
    Therefore it can't refresh the page when the server is done.

    One approach to overcome this limitation is to poll the server for its
    status. Some JavaScript would send a request to the server in intervals,
    then trigger the refresh when the server reported "done".

    This polling can be done using a traditional web page handler, or
    potentially lighter using a custom CLI command called over json/rpc. You
    don't have to use a CLI command. A regular web page handler could be
    good enough.

    --

    Michael
    Thanks Michael - I tried a Slim::Web::Pages->addPageFunction but could not get that to work as I wanted. As this is a one time 'event' in the configuration of the plugin (to validate Oauth authorization), I've added a manual page update that must be done by the user. I hope it will be a minor inconvenience, I'll see the feedback.
    LMS 7.7, 7.8 and 7.9 - 5xRadio, 3xBoom, 4xDuet, 1xTouch, 1 SB2. Sonos PLAY:3, PLAY:5, Marantz NR1603, JBL OnBeat, XBoxOne, XBMC, Foobar2000, ShairPortW, JRiver 21, 2xChromecast Audio, Chromecast v1 and v2, , Pi B3, B2, Pi B+, 2xPi A+, Odroid-C1, Odroid-C2, Cubie2, Yamaha WX-010, AppleTV 4, Airport Express

  6. #6
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    19,757

    Refreshing a setting page in callback

    > Thanks Michael - I tried a Slim::Web::Pages->addPageFunction but could
    > not get that to work as I wanted.


    How did it fail?

    --

    Michael

  7. #7
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    3,241
    Quote Originally Posted by mherger View Post
    > Thanks Michael - I tried a Slim::Web::Pages->addPageFunction but could
    > not get that to work as I wanted.


    How did it fail?

    --

    Michael
    It's me not understanding how it should work, so it's my fault, nothing wrong with LMS.

    Normally, the settings page of the plugin is a child of Slim::Web::Settings and there is a handler to manage user inputs and set parameters. That works, but because I have HTTP call (async) there, the result of this HTTP call cannot be displayed, unless the page is refreshed and the handler called (I just need to displayed one string)

    So I added a Slim::Web::Pages->addPageFunction with a proper regex to serve that setting page and that worked, the handler set in that addPageFunction is called. What I did not understand well what to do in that handler and how to use Slim::Web::HTTP::filltemplatefile, which I thought was needed to fill the web page but I did not understand how/if its interacts with the handler of Slim::Web::Settings. Do I have to fill *all* the $params of the setting page and passe them to the filltemplatefile call but then what happens with the handler of Slim::Web::settings?
    Last edited by philippe_44; 2017-01-30 at 14:32.
    LMS 7.7, 7.8 and 7.9 - 5xRadio, 3xBoom, 4xDuet, 1xTouch, 1 SB2. Sonos PLAY:3, PLAY:5, Marantz NR1603, JBL OnBeat, XBoxOne, XBMC, Foobar2000, ShairPortW, JRiver 21, 2xChromecast Audio, Chromecast v1 and v2, , Pi B3, B2, Pi B+, 2xPi A+, Odroid-C1, Odroid-C2, Cubie2, Yamaha WX-010, AppleTV 4, Airport Express

  8. #8
    Senior Member
    Join Date
    Jan 2011
    Location
    Germany
    Posts
    242
    Maybe my code might help here as I had a similar problem with updating pages.

    Here is a handler that get special update treatment.
    Maybe this helps as an entry point.

    https://github.com/chincheta0815/Hue...ettings.pm#L77

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •