Player APIs (BrightScript & Ja...
...
Object Reference
Presentation and Widget Object...
roNodeJsEvent
3min
if an romessageport is attached to an ronodejs , it will receive ronodejsevent objects when something happens to the parent ronodejs instance ifuserdata setuserdata(user data as object) sets the user data that will be returned when events are raised getuserdata() as object returns the user data that has previously been set via setuserdata() it will return invalid if no data has been set ifnodejsevent getdata() as roassociativearray returns the event data as an associative array with the following key/value pairs reason string string the cause of the event, which can be one of the following process exit the nodejs instance has exited message the nodejs instance has sent a message exit code number number this field is only present if the value of the reason field value is process exit it will return the exit code from the node js® process, as described at https //nodejs org/api/process html#process exit codes https //nodejs org/api/process html#process exit codes the exit code field is only defined from os 8 2 onwards note that the node js script could also use these codes for its own purposes message string string if the reason field value is message , this field returns the contents of the message example the following event loop waits for a nodejs event and reports the events while true ev = wait(0, gaa mp) print "=== bs received event ";type(ev) if type(ev) = "ronodejsevent" then eventdata = ev getdata() if type(eventdata) = "roassociativearray" and type(eventdata reason) = "rostring" then if eventdata reason = "process exit" then print "=== bs node js instance exited with code " ; eventdata exit code else if eventdata reason = "message" then print "=== bs received message "; eventdata message ' to use this msgport postbsmessage({text "my message"}); else print "======= unhandled nodejs event =========" print eventdata reason endif else print "=== bs unknown eventdata "; type(eventdata) endif endif endwhile