Custom Roku BrightScript commands can be added to the Roku BrightScript client.
The application should override the default customCommands.brs
file to inject additional client commands that can be invoked using the invokeCommand
function.
Do the following steps to add a custom BrightScript command:
customCommands.brs
that is found in the <Engine Version>/src/cloud/source folder.customCommands.brs
(or any other required .brs file in the app’s roku client folder).Register the new custom function with the initCustomCommands()
function with customCommands.brs
as shown in the following example:
sub initCustomCommands()
' first parameter of addCustomCommand is the string name of the command to be used by the server app.
' The second parameter is the action function or sub that is bound to the command name.
addCustomCommand("customCommand1", command1Implementation)
addCustomCommand("getInfoWithResponse", getDeviceInfoCommand)
end sub
sub command1Implementation(params as object)
'Some BrightScript function
end sub
sub getDeviceInfoCommand(params as object)
deviceInfo = CreateObject("roDeviceInfo")
' The sequence number of the request must be included if a response is sent back
response = {event: "response", sequence: m.lastSequence}
response["version"] = deviceInfo.GetVersion()
response["externalip"] = deviceInfo.GetExternalIp()
response["connectiontype"] = deviceInfo.GetConnectionType()
response["graphics"] = deviceInfo.GetGraphicsPlatform()
sendObjectAsJSON(response)
end sub
The Cloud Solution provides the invokeCommand function to invoke the named function.
No results yet. Please begin typing a keyword to search the You.i TV Developer Portal...
Try to search with a different keyword or remove search filters.