I am creating my own node app (or two) and autorun.brs file. I have been able to use the autorun examples I have found so far, but I want to do things that are more complicated than most of what I'm seeing out there (specifically run an express server and a front end). I need to know if I can run two things at the same time and if I can, how I can accomplish this. Really I just want to know what the autorun is capable of but cannot find documentation anywhere.
3 comments
-
Bright Scripters The BrightScript documentation might be what you are looking for
https://brightsign.atlassian.net/wiki/spaces/DOC/pages/370672718/BrightScript
For multiple node.js services you could instantiate multiple roNodeJs objects.
https://brightsign.atlassian.net/wiki/spaces/DOC/pages/404619466/roNodeJs
-
Brandon Stryker Hey that looks right up my alley :) after creating the nodejs object is there something I need to do to run it? For example:
If I have this line of code like in the documentationnode = CreateObject(
"roNodeJs"
,
"index.js"
, {message_port:my_message_port, arguments: [
"arg1"
,
"arg2"
]})
would I need a command line node.run() or node.show() ater that line?update: I uploaded my app to the device sd card. From an ssh session I can run "node app.js" and the presentation runs and I can navigate to different urls and call functions on the express server. We can close this issue if you can tell me how to do this exact same thing in my autorun.brs file :) (I have other issues but I'll open other questions for those)
-
Brandon Stryker Ok I figured it out, thanks for the help. Posting autorun here in case anyone else ever sees this. You can close this issue
sub Main()
m.GLOBAL_DEBUG = true
debug_out("Beginning Main")
' enable ssh
reg = CreateObject("roRegistrySection", "networking")
reg.write("ssh", "22")
n = CreateObject("roNetworkConfiguration", 0)
n.SetLoginPassword("password")
n.Apply()
reg.flush()
debug_out("SSH Enabled")
' do something with player id maybe
info = CreateObject("roDeviceInfo")
m.PlayerId = info.GetDeviceUniqueId()
r = CreateObject("roRectangle", 0, 0, 1920, 1080)
is = {
port: 2999
}
config = {
nodejs_enabled: true
inspector_server: is
security_params: {
websecurity: false
}
brightsign_js_objects_enabled: true
url: "file:///sd:/frontend/build/index.html"
}
m.mPort = CreateObject("roMessagePort")
m.node = CreateObject("roNodeJS", "app.js", {message_port: m.mPort})
m.h = CreateObject("roHtmlWidget", r, config)
m.h.Show()
while true
' do nothing
endwhile
end sub
sub debug_out(any)
if m.GLOBAL_DEBUG then print any
end sub