Example #1
0
        /// <summary>
        /// Updates the UPnP server advertisements.
        /// </summary>
        /// <remarks>
        /// Has to be called when the set of UPnP endpoints changes.
        /// </remarks>
        public void Update()
        {
            int nextBootId = _serverData.BootId + 1;

            DeviceTreeNotificationProducer.SendMessagesServer(_serverData.Server, new UpdateMessageSender(_serverData, _serverData.BootId, nextBootId));
            _serverData.BootId = nextBootId;
        }
Example #2
0
 protected void ProcessSearchRequest(PendingSearchRequest ps)
 {
     lock (_serverData.SyncObj)
     {
         SearchResultMessageSender srms = new SearchResultMessageSender(_serverData, ps.LocalEndpointConfiguration, ps.RequesterEndPoint);
         if (ps.ST == "ssdp:all")
         {
             DeviceTreeNotificationProducer.SendMessagesServer(_serverData.Server, srms);
         }
         else if (ps.ST == "upnp:rootdevice")
         { // Search root device
             foreach (DvDevice rootDevice in _serverData.Server.RootDevices)
             {
                 string deviceUDN = rootDevice.UDN;
                 srms.SendMessage("upnp:rootdevice", deviceUDN + "::upnp:rootdevice", rootDevice);
             }
         }
         else if (ps.ST.StartsWith("uuid:"))
         { // Search by device id
             string   deviceUDN = ps.ST;
             DvDevice device    = _serverData.Server.FindDeviceByUDN(deviceUDN);
             if (device != null)
             {
                 srms.SendMessage(deviceUDN, deviceUDN, device.RootDevice);
             }
         }
         else if (ps.ST.StartsWith("urn:") && (ps.ST.IndexOf(":device:") > -1 || ps.ST.IndexOf(":service:") > -1))
         { // Search by device type or service type and version
             string type;
             int    version;
             if (!ParserHelper.TryParseTypeVersion_URN(ps.ST, out type, out version))
             {
                 UPnPConfiguration.LOGGER.Debug("SSDPServerController: Problem parsing incoming packet, UPnP device or service search query '{0}'", ps.ST);
                 return;
             }
             if (type.IndexOf(":device:") > -1)
             {
                 IEnumerable <DvDevice> devices = _serverData.Server.FindDevicesByDeviceTypeAndVersion(
                     type, version, true);
                 foreach (DvDevice device in devices)
                 {
                     srms.SendMessage(device.DeviceTypeVersion_URN, device.UDN + "::" + device.DeviceTypeVersion_URN, device.RootDevice);
                 }
             }
             else if (type.IndexOf(":service:") > -1)
             {
                 foreach (DvDevice rootDevice in _serverData.Server.RootDevices)
                 {
                     IEnumerable <DvService> services = rootDevice.FindServicesByServiceTypeAndVersion(
                         type, version, true);
                     foreach (DvService service in services)
                     {
                         srms.SendMessage(service.ServiceTypeVersion_URN, service.ParentDevice.UDN + "::" + service.ServiceTypeVersion_URN, service.ParentDevice.RootDevice);
                     }
                 }
             }
         }
     }
 }
Example #3
0
 /// <summary>
 /// Revokes all UPnP server advertisements.
 /// </summary>
 public void RevokeAdvertisements()
 {
     DeviceTreeNotificationProducer.SendMessagesServer(_serverData.Server, new ByeByeMessageSender(_serverData));
 }
Example #4
0
 /// <summary>
 /// Advertises the UPnP server to the network.
 /// </summary>
 /// <remarks>
 /// Has to be called:
 /// <list type="bullet">
 /// <item>Periodically</item>
 /// <item>After the set of UPnP endpoints has changed</item>
 /// <item>When the underlaying UPnP server changes its configuration</item>
 /// </list>
 /// </remarks>
 public void Advertise()
 {
     DeviceTreeNotificationProducer.SendMessagesServer(_serverData.Server, new AliveMessageSender(_serverData));
 }