i am setting a task node field and trying to observe that field in another component, I have also created the task node object in the component in which i want to access the field. But however i am not able to access the callback function associated with it. Please help anyone
This is my logintask.xml
<?xml version="1.0" encoding="UTF-8"?> <component name="logintask" extends="Task"> <interface> <field id="result" type="assocarray" alwaysNotify="true" /> <field id="content" type="node" /> <field id="urlfield" type="string" /> <field id="username" type="string" /> <field id="password" type="string" /> <field id="token" type="string" /> <field id="user_id" type="string" /> <field id="msg" type="string" alwaysNotify="true" /> </interface> <script type="text/brightscript" uri="pkg:/components/src/logintask.brs" /> </component>
this is my logintask.brs here i am setting the result field
sub init() m.top.functionName = "userLogin" end sub Function userLogin() sec = CreateObject("roRegistrySection", "Authentication") sec.Write("Urlfield", m.top.urlfield) sec.Write("Username", m.top.username) sec.Write("Password", m.top.password) sec.Flush() m.global.urlfield = m.top.urlfield m.global.username = m.top.username m.global.password = m.top.password url = CreateObject("roUrlTransfer") url.SetPort(CreateObject("roMessagePort")) url.SetUrl("http://"+m.top.urlfield+"/third_law/player_api.php") rsp = url.AsyncPostFromString("username="+m.top.username+"&password="+m.top.password) event = wait(5000, url.GetPort()) if type(event) = "roUrlEvent" if event.GetResponseCode() = 200 response = ParseJson(event.GetString()) if response <> invalid getTvCategories() else m.top.msg = "Connection error" endif else m.top.msg = "Connection error" endif else if event = invalid m.top.msg = "Connection timeout" url.AsyncCancel() else m.top.msg = "Connection error" endif End Function function getTvCategories() url = CreateObject("roUrlTransfer") url.SetPort(CreateObject("roMessagePort")) url.SetUrl("http://"+m.top.urlfield+"/third_law/panel_api.php") rsp = url.AsyncPostFromString("username="+m.top.username+"&password="+m.top.password) event = wait(5000, url.GetPort()) if type(event) = "roUrlEvent" if event.GetResponseCode() = 200 response = ParseJson(event.GetString()) if response <> invalid m.global.tv_grp = response.categories.live channels = CreateObject("roAssociativeArray") while response.available_channels.IsNext() available_channels = response.available_channels.Next() eachBlock = response.available_channels[available_channels] streamType = eachBlock.stream_type if streamType = "live" channels.AddReplace(available_channels,eachBlock) m.global.TvChannels = channels end if end while getVodCategories() else m.top.msg = "Connection error" endif else m.top.msg = "Connection error" endif else if event = invalid m.top.msg = "Connection timeout" url.AsyncCancel() else m.top.msg = "Connection error" endif m.top.result = m.global.TvChannels ?m.top end function function getVodCategories() url = CreateObject("roUrlTransfer") url.SetPort(CreateObject("roMessagePort")) url.SetUrl("http://"+m.top.urlfield+"/third_law/panel_api.php") rsp = url.AsyncPostFromString("username="+m.top.username+"&password="+m.top.password) event = wait(5000, url.GetPort()) if type(event) = "roUrlEvent" if event.GetResponseCode() = 200 response = ParseJson(event.GetString()) if response <> invalid m.global.vod_grp = response.categories.movie movie = CreateObject("roAssociativeArray") while response.available_channels.IsNext() available_channels = response.available_channels.Next() eachBlock = response.available_channels[available_channels] streamType = eachBlock.stream_type if streamType = "movie" movie.AddReplace(available_channels,eachBlock) m.global.VodList = movie end if end while else m.top.msg = "Connection error" endif else m.top.msg = "Connection error" endif else if event = invalid m.top.msg = "Connection timeout" url.AsyncCancel() else m.top.msg = "Connection error" endif m.top.msg = "OK" end function
this is my livetvscreen.brs where i want to access the result field of logintask which is a task node
sub init() m.tvGenresList = m.top.FindNode("tvGenresList") m.tvmarkuplist = m.top.findNode("TvMarkupList") m.tvlisttask = createObject("roSGNode", "logintask") ? m.tvlisttask m.tvlisttask.ObserveField("result", "onGetList") m.tvlistcontent = m.top.findNode("tvListContent") m.itemcount = 0 m.channelbox = m.top.findNode("channelbox") m.categoryname = m.top.findNode("categoryname") m.time = m.top.findNode("currenttime") m.date = m.top.findNode("currentdate") m.testtimer = m.top.findNode("testTimer") m.testtimer.control = "start" m.testtimer.ObserveField("fire","dateTimeupdate") dateTimeupdate() end sub function get() ?"get()" m.tvlisttask.urlfield = m.global.urlfield m.tvlisttask.username = m.global.username m.tvlisttask.password = m.global.password m.tvlisttask.control = "RUN" endfunction function onGetList() as void ?"onGetList() called" end function function tvgrpload() m.tvGenresList.content = m.top.tvgrp end function function onKeyEvent(key as String, press as Boolean) as Boolean if key = "OK" and press then if m.categoryname.hasFocus() m.channelbox.visible = true m.categoryname.SetFocus(false) m.tvGenresList.visible = true m.tvGenresList.SetFocus(true) endif endif if key = "back" and press then m.top.goback = true end if end function function dateTimeupdate() date = CreateObject("roDateTime") currdate = date.AsDateString("long-date") m.date.text = currdate date.ToLocalTime() min = date.GetMinutes() hrs = date.GetHours() if date.GetHours() < 12 then newhrs = hrs.ToStr() if date.GetMinutes() < 10 newmin = ("0"+ min.ToStr()).ToStr() else newmin = min.ToStr() end if updatedHour = newhrs + ":" + newmin +"AM" m.time.text = updatedHour else newhrs = (hrs - 12).ToStr() if date.GetMinutes() < 10 newmin = ("0"+ min.ToStr()).ToStr() else newmin = min.ToStr() end if updatedHour = newhrs + ":" + newmin +"PM" m.time.text = updatedHour endif end function
can anybody tell me why i am not been able to call the onGetList function when i am setting the result field. Please help somebody
We’re upgrading Roku Community to bring you a faster, more mobile-friendly experience. You may notice limited functionality or read-only access during this time. You will not be able to log in or post new comments or kudos during this time. Read more here.
Planned Downtime:
Community will be unavailable for up to 24–48 hours during the upgrade window during the week of May 12 and you may notice reduced functionality.
In the meantime, for additional assistance, visit our Support Site.
Thanks for your patience — we’re excited to share what’s next!