"adrianc1982" wrote:
Does anyone has a working example or ecp for inputs?
Sub Main ()
inputObject = CreateObject ("roInput")
port = CreateObject ("roMessagePort")
inputObject.SetMessagePort (port)
While True
msg = Wait (0, port)
If Type (msg) = "roInputEvent"
info = msg.GetInfo ()
Print info
EndIf
End While
End Sub
The trick to sending an ECP input request is to ensure that you use the HTTP POST verb (not GET), and put the arguments in the QUERY STRING (NOT in the request body). This is a non-conventional practice. Normally, if you have query string arguments with no message body, you'd use a GET request; if you wanted to use a POST request, you'd put the arguments in the body. However, Roku chooses to do things differently, for whatever reason, and you have to make sure you use a POST with a query string and an empty message body.
In Python, for example:
import urllib.parse
import requests
params = {'a': 123, 'b':'Hello, World!'}
r = requests.post ('http://192.168.0.6:8060/input?' + urllib.parse.urlencode (params))
BrightScript Debugger> ------ Running ------
a: 123
b: Hello, World!
Note also that even if an argument had an integer value, it will be received as a roString in your BrightScript code.