I think I see what you're trying to do now. I didn't get it the first time I looked at your sample code because it didn't do anything.
I wrote my own code that I think does what you're trying to do, and get the same result: An ECP command fails with HTTP error code 503 (Service Unavailable) when attempted after a progress dialog has been dismissed and replaced by a normal dialog. I tried a few workarounds to no avail. It looks like a bug to me.
Here's my code:
MainScene.xml<?xml version="1.0" encoding="UTF-8"?>
<component name="MainScene" extends="Scene">
<script type="text/brightscript" uri="pkg:/components/MainScene.brs" />
<children>
<Timer id="timer" duration="5" control="start" />
<Ecp id="ecp" />
</children>
</component>
MainScene.brssub init()
m.ecp = m.top.findNode("ecp")
m.timer = m.top.findNode("timer")
m.timer.ObserveField("fire", "onFire")
m.top.SetFocus(true)
'>>>> COMMENT THE FOLLOWING LINE: ECP WORKS <<<<<'
'>>>> UN-COMMENT THE FOLLOWING LINE: ECP FAILS WITH ERROR 503 <<<<'
m.top.dialog = CreateObject("roSGNode", "ProgressDialog")
end sub
sub onFire()
m.dialog = CreateObject("roSGNode", "Dialog")
m.dialog.title = "Dialog Title"
m.dialog.buttons = ["Run Netflix", "Cancel"]
m.dialog.ObserveField("buttonSelected", "onButtonSelected")
m.top.dialog = m.dialog
end sub
sub onButtonSelected()
if m.dialog.buttonSelected = 0
m.ecp.ecpExec = "http://localhost:8060/launch/12"
m.ecp.control = "RUN"
else
m.dialog.close = true
end if
end sub
Ecp.xml<?xml version="1.0" encoding="UTF-8"?>
<component name="Ecp" extends="Task">
<script type="text/brightscript" uri="pkg:/components/Ecp.brs" />
<interface>
<field id="ecpExec" type="uri" />
</interface>
</component>
Ecp.brssub init()
m.top.functionName = "taskRun"
end sub
function taskRun() as void
port = CreateObject("roMessagePort")
ut = CreateObject("roUrlTransfer")
ut.SetPort(port)
ut.SetUrl(m.top.ecpExec)
ut.AsyncPostFromString("")
msg = Wait(0, port)
print "ResponseCode: "; msg.GetResponseCode(); " FailureReason: "; msg.GetFailureReason()
end function
The error I get, unless the m.top.dialog assignment is commented out in MainScene.brs/init() is:
ResponseCode: 503 FailureReason: The requested URL returned error: 503 Service Unavailable