Yortw / RSSDP

Really Simple Service Discovery Protocol - a 100% .Net implementation of the SSDP protocol for publishing custom/basic devices, and discovering all device types on a network.
http://yortw.github.io/RSSDP/
MIT License
282 stars 66 forks source link

Advertise C# WCF app so that it appears in the Network explorer #113

Open lathoub opened 2 years ago

lathoub commented 2 years ago

Hi

I have made a c# application that expose a WCF service and I would like to advertise that service in Windows using SSDP.

My Question: - what do I have to do so that it becomes visible in the Network Explorer (in the green circle in the attached screenshot) (similar to the 2 synology NAS's)

Screenshot 2022-05-22 at 09 34 23

Here is what I currently do :

From the examples, I was able to make the server example work:

// Create the device(s) we want to publish.
var url = new Uri("http://192.168.0.245:8181/");

var rootDevice = new SsdpRootDevice()
{
DeviceType = "Basic",
    FriendlyName = "Sample RSSDP Device",
    Manufacturer = "RSSDP",
    ManufacturerUrl = new Uri("https://github.com/Yortw/RSSDP"),
    ModelDescription = "Test Device from RSSDP Console App",
    ModelName = "RSSDP Sample Device",
    ModelNumber = "123", 
    ModelUrl = new Uri("https://github.com/Yortw/RSSDP"),
    SerialNumber = "123",
    CacheLifetime = TimeSpan.FromMinutes(30),
    PresentationUrl = new Uri("http://192.168.0.245:8080/unit15/v1.0/"),
    Uuid = System.Guid.NewGuid().ToString(),
    UrlBase = url
};

var service = new SsdpService()
{
    ServiceType = "Dummy",
    Uuid = System.Guid.NewGuid().ToString(),
    ServiceTypeNamespace = "",
    ControlUrl = new Uri("/dummy", UriKind.Relative),
    EventSubUrl = new Uri("/dummy", UriKind.Relative),
    ScpdUrl = new Uri("/ssdp/dummy.xml", UriKind.Relative)
};
rootDevice.AddService(service);

rootDevice.Location = new Uri(url, "ddd");

The HttpListener serves the above document just fine on http://192.168.0.245:8181/ddd.

<root xmlns="urn:schemas-upnp-org:device-1-0">
  <specVersion>
    <major>1</major>
    <minor>0</minor>
  </specVersion>
  <URLBase>http://192.168.0.245:8181/</URLBase>
  <device>
    <deviceType>urn:schemas-upnp-org:device:Basic:1</deviceType>
    <friendlyName>Sample RSSDP Device</friendlyName>
    <manufacturer>RSSDP</manufacturer>
    <manufacturerURL>https://github.com/Yortw/RSSDP</manufacturerURL>
    <modelDescription>Test Device from RSSDP Console App</modelDescription>
    <modelName>RSSDP Sample Device</modelName>
    <modelNumber>123</modelNumber>
    <modelURL>https://github.com/Yortw/RSSDP</modelURL>
    <presentationURL>http://192.168.0.245:8080/unit15/v1.0/</presentationURL>
    <serialNumber>123</serialNumber>
    <UDN>uuid:e5d01f19-e113-42e3-aa08-1648e439d1bc</UDN>
    <serviceList>
      <service>
        <serviceType>urn::service:Dummy:1</serviceType>
        <serviceId>urn::serviceId:4ddedf43-0c6e-4080-8e73-f73cb8ad2d56</serviceId>
        <SCPDURL>/ssdp/dummy.xml</SCPDURL>
        <controlURL>/dummy</controlURL>
        <eventSubURL>/dummy</eventSubURL>
      </service>
    </serviceList>
  </device>
</root>

Thanks!