Help reading remote variable

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
sinbad
Posts: 40
Joined: 01 Mar 2018, 09:32

Help reading remote variable

06 Aug 2019, 11:59

I'm trying to control a script remotely. I can do most things ok, but I'm having trouble getting the status of a variable from a running script. Here's my test setup. The server status can be in three states "READY", "BUSY" and "RELOAD" but I can't seem to get it to report when it's "BUSY".

server.ahk

Code: Select all

#include Jxon.ahk
#include Socket.ahk
#include RemoteObj.ahk
#include AhkDllThread.ahk
#include ObjRegisterActive.ahk

ObjToPublish := new MyServer()
Bind_Addr := A_IPAddress1
Bind_Port := 8337
Server := new RemoteObj(ObjToPublish, [Bind_Addr,Bind_Port])
; ObjRegisterActive(Server, "{93C04B39-0465-4460-8CA0-7BFFF481FF98}")
return

class MyServer {

        __New() {
            STATUS := "READY"
        }

        STATUS {
            get {
                if FileExist( "status.ini" ) {	
		            IniRead, STATUS, status.ini, General, STATUS
                }
                return STATUS
            }
            set {
                IniWrite, %value%, status.ini, General, STATUS
                return STATUS
            }
        }
        
        start() 
        {
            this.STATUS := "BUSY"            
            AhkThread := AhkDllThread(AhkDllPath)
            AhkThread.ahktextdll(this.runLong())
        }

        runLong() 
        {
            sleep 10000
            this.STATUS := "READY"
        }

        reloadScript() {
            this.STATUS := "RELOAD"
            Reload
        }

}

^!r::Reload
client.ahk

Code: Select all

#include Jxon.ahk
#include Socket.ahk
#include RemoteObj.ahk
#include AhkDllThread.ahk
#singleInstance force

serverAddr := A_IPAddress1
serverPort := 8337
Remote := new RemoteObjClient([serverAddr, serverPort])
msgbox % Remote.STATUS ;READY/RELOAD
AhkThread := AhkDllThread(AhkDllPath)
AhkThread.ahktextdll(Remote.start())
msgbox % Remote.STATUS ;READY
Remote.reloadScript()
sleep 3000
msgbox % Remote.STATUS ;RELOAD

^+r::Reload

sinbad
Posts: 40
Joined: 01 Mar 2018, 09:32

Re: Help reading remote variable

06 Aug 2019, 12:27

I'm just thinking aloud here. This might be due to blocking in the socket....

Edit: Changing blocking to False caused every test to return empty.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: MrHue, Rohwedder, Rxbie, songdg and 381 guests