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!

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

@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.

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.