Пример #1
0
        void ClientServiceEvent(Mono.Ssdp.ServiceArgs args,
                                Action <DeviceAnnouncement> deviceHandler,
                                Action <ServiceAnnouncement> serviceHandler)
        {
            if (!args.Usn.StartsWith("uuid:"))
            {
                return;
            }

            var colon = args.Usn.IndexOf(':', 5);
            var usn   = colon == -1 ? args.Usn : args.Usn.Substring(0, colon);

            if (args.Usn.Contains(":device:"))
            {
                var type   = DeviceType.Parse(args.Service.ServiceType);
                var device = new DeviceAnnouncement(this, type, usn, args.Service.Locations);
                deviceHandler(device);
            }
            else if (args.Usn.Contains(":service:"))
            {
                var type    = ServiceType.Parse(args.Service.ServiceType);
                var service = new ServiceAnnouncement(this, type, usn, args.Service.Locations);
                serviceHandler(service);
            }
        }
Пример #2
0
 internal ServiceDescription GetDescription(ServiceAnnouncement announcement)
 {
     foreach (var uri in announcement.Locations)
     {
         if (descriptions.ContainsKey(uri))
         {
             var description = GetDescription(announcement, descriptions[uri]);
             if (description != null && !description.IsDisposed)
             {
                 return(description);
             }
         }
         try {
             var deserializer = deserializer_factory.CreateDeserializer();
             var rootDevice   = deserializer.DeserializeDescription(new Uri(uri));
             if (rootDevice == null)
             {
                 continue;
             }
             descriptions[uri] = rootDevice;
             return(GetDescription(announcement, rootDevice));
         } catch (Exception e) {
             Log.Exception(string.Format("There was a problem fetching the description at {0}.", uri), e);
         }
     }
     return(null);
 }
Пример #3
0
 ServiceDescription GetDescription(ServiceAnnouncement announcement, DeviceDescription device)
 {
     foreach (var description in device.Services)
     {
         if (device.Udn == announcement.DeviceUdn && announcement.Type == description.Type)
         {
             return(description);
         }
     }
     foreach (var childDevice in device.Devices)
     {
         var description = GetDescription(announcement, childDevice);
         if (description != null)
         {
             return(description);
         }
     }
     return(null);
 }
Пример #4
0
 internal Service GetService(ServiceAnnouncement announcement)
 {
     return(GetDescription <ServiceAnnouncement, Service> (announcement.Locations, announcement, GetService));
 }
 public ConnectionManagerController (ServiceAnnouncement announcement)
 {
     if (announcement == null) throw new ArgumentNullException ("announcement");
     controller = announcement.GetService ().GetController ();
     Verify ();
 }
Пример #6
0
 public ServiceEventArgs(ServiceAnnouncement service, UpnpOperation operation)
 {
     this.service   = service;
     this.operation = operation;
 }
Пример #7
0
 public ServiceEventArgs (ServiceAnnouncement service, UpnpOperation operation)
 {
     this.service = service;
     this.operation = operation;
 }