Results 1 to 1 of 1

Thread: How do I account for a computer being offline in socket.http.request?

  1. #1
    Join Date
    Jul 2001
    Location
    Risør - Norway
    Posts
    5,477

    Default How do I account for a computer being offline in socket.http.request?

    Never mind, found a way:

    Code:
    if http.request("http://192.168.0.15:8080/") == nil
    then
    print ("Nothing here")
    else
    print ("Here we are")
    end

    I have this code to check if JRMC is playing:

    Code:
    local _, _, PlayMode = string.find(socket.http.request('http://192.168.0.15/MCWS/v1/Playback/Info?Zone=' .. SoneVariable .. '&ZoneType=Index'), 'State">(%d+)<')
    The problem comes when the computer it checks is offline, or JRMC has exited with an error, or something like that. It doesn't happen often (maybe every third month or so), but I would like to have a check for that, but I get:

    bad argument #1 to `find' (string expected, got nil)
    So is there any way to check if JRMC is offline and have a new action happen in that cas? I can create the action, so let's just say:

    Code:
    print("JRMC is offline")
    And if it's online just continue the script as usual.
    Last edited by Mastiff; May 26th, 2016 at 04:54 AM.
    Tor - managing director of the Cinema Inferno home theater and multi-zone sound system with Girder running the show in the back, NetRemote as the GUI and Media Center 17, PowerDVD and ZoomPlayer as playback software
    Hobsyssel mastiffs: http://www.hobsyssel.no

Posting Permissions

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