0

I am trying to find my Roku TV on my network and apparently it needs some SSDP discovery based on Roku API help, however, I am unable to search for my device with any of the Nuget libraries.

I came across ssdpradar and was able to install the Nuget package for Visual Studio (VB.NET) through Visual Studio 2017 community release. However, I am not able to find any documentation on how to use it.

Any advice would be helpful.

Solution:

I found a solution but not with ssdpradar and rather RSSDP. After you add the nugget in your project you can use the following line of code to get all devices and then find the Roku location (ip+port) from that list.

Imports Rssdp

For Each founddevice As DiscoveredSsdpDevice In founddevices.Result
    If founddevice.Usn.Contains("roku:ecp") Then
        Rokulocation = founddevice.DescriptionLocation.ToString()
        Exit For
    End If
Next
Afshin Rahimi
  • 164
  • 1
  • 1
  • 12

1 Answers1

0

I was able to successfully use a library called RokuDotNet recently. It's written in C# but you could load it as a project in your solution and reference it from VB.NET.

This is roughly the way I used it:

Imports RokuDotNet.Client

Public Class Form1
    Private _discoveryClient As RokuDeviceDiscoveryClient

    Public Sub New()
        _discoveryClient = New RokuDeviceDiscoveryClient
        AddHandler _discoveryClient.DeviceDiscovered, AddressOf DiscoveryHandler
    End Sub

    Private Sub Form1_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
        _discoveryClient.DiscoverDevicesAsync()
    End Sub

    Private Async Sub DiscoveryHandler(sender As Object, e As DeviceDiscoveredEventArgs)
        If InvokeRequired Then
            BeginInvoke(New Action(Sub() DiscoveryHandler(sender, e)))
            Return
        End If

        ' Get the display name for the device (if the user entered one when setting it up)
        Dim deviceInfo = Await e.Device.Query.GetDeviceInfoAsync
        Dim name = deviceInfo.UserDeviceName
        If String.IsNullOrEmpty(name) Then
            name = deviceInfo.ModelName
        End If
        AddDevice(e.Device, name)
    End Sub

    Private Sub AddDevice(device As RokuDevice, name As String)
        ' Your code here
    End Sub
End Class

You might want to add a try/catch around the await in that async function so it can show an error if there's a network problem.

libertyernie
  • 2,590
  • 1
  • 17
  • 13