Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
adamkaz
Channel Surfer

Measuring User Connection Speed in Scenegraph Application

I'm want to display a diagnostics page to my users. As part of that, I would like to display their current connection speed. In previous applications, I've used the measured speed from the video (through roVideoPlayerEvent) or from the system log (through roSystemLog). Since neither of these are available in scenegraph applications, is there an alternative to get this metric?

Thanks!
0 Kudos
3 REPLIES 3
RobSMS
Visitor

Re: Measuring User Connection Speed in Scenegraph Applicatio

This worked for me...

Setup a roSystemLog event in the main thread that pushes .bandwidth to the global var. Then just use an observeField on the global var that pushes the data to the Render node.

So for example....


Sub RunUserInterface(args As Object)
screen = CreateObject("roSGScreen")
scene = screen.CreateScene("HomeScene")
port = CreateObject("roMessagePort")

m.global = screen.getGlobalNode()
m.global.addFields( { bandwidthMetric: 0 } )

syslog = CreateObject("roSystemLog")
syslog.SetMessagePort(port)
syslog.EnableType("bandwidth.minute")

while true
msg = wait(0,port)
if type(msg) = "roSystemLogEvent" then
i = msg.GetInfo()
if i.LogType = "bandwidth.minute" then

m.global.bandwidth = i.bandwidth
end if
end if
end while
End Sub


Then in your scenegraph init...

Function Init()
m.global.ObserveField("bandwidth", "PushToScreen")
End Function

Sub PushToScreen()
m.bandwidth = m.top.findNode("Bandwidth")
m.bandwidth.text = "Bandwidth: " + m.global.bandwidth.toStr()
End Sub
Need Apps Templates? Content Management for OTT/IPTV? Check me out @ http://rovidx.com
0 Kudos
adamkaz
Channel Surfer

Re: Measuring User Connection Speed in Scenegraph Applicatio

@RobSMS: Nice example! Thanks. This helped me get going. I had to make a couple minor tweaks to get it to work. I think you made a typo here:
m.global.addFields( { bandwidthMetric: 0 } )
should be:
m.global.addFields( { bandwidth: 0 }
Also, the observe only worked for me if I declared the global and added the bandwidth field BEFORE I created the scene.
0 Kudos
RobSMS
Visitor

Re: Measuring User Connection Speed in Scenegraph Applicatio

Nope, not a typo... its a global var so you could name it what ever you wanted.

I just hacked out the code from memory, so if there are errors, don't be surprised.
Need Apps Templates? Content Management for OTT/IPTV? Check me out @ http://rovidx.com
0 Kudos