public SatIpDeviceInformation(SatIpDevice device)
        {
            InitializeComponent();
            this.device              = device;
            tbxDeviceType.Text       = device.DeviceType;
            tbxFriendlyName.Text     = device.FriendlyName;
            tbxManufacture.Text      = device.Manufacturer;
            tbxModelDescription.Text = device.ModelDescription;
            tbxUniqueDeviceName.Text = device.UniqueDeviceName;
            tbxManufactureUrl.Text   = device.ManufacturerUrl;
            tbxPresentationUrl.Text  = device.PresentationUrl;
            pbxDVBC.Image            = Resources.dvb_c;
            pbxDVBC.Visible          = device.SupportsDVBC;
            pbxDVBS.Image            = Resources.dvb_s;
            pbxDVBS.Visible          = device.SupportsDVBS;
            pbxDVBT.Image            = Resources.dvb_t;
            pbxDVBT.Visible          = device.SupportsDVBT;

            try
            {
                var imageUrl =
                    string.Format(device.FriendlyName == "OctopusNet" ? "http://{0}:{1}/{2}" : "http://{0}:{1}{2}",
                                  device.BaseUrl.Host, device.BaseUrl.Port, device.GetImage(1));
                pbxManufactureBrand.LoadAsync(imageUrl);
                pbxManufactureBrand.Visible = true;
            }
            catch
            {
                pbxManufactureBrand.Visible = false;
            }
        }
Example #2
0
        public SatIpDevice FindByUDN(string uuid)
        {
            SatIpDevice device = null;

            if (_devices.ContainsKey(uuid))
            {
                _devices.TryGetValue(uuid, out device);
            }
            return(device);
        }
        /// <summary>
        ///     The UnicastReceiveCallback receives Http Responses
        ///     and Fired the SatIpDeviceFound Event for adding the SatIpDevice
        /// </summary>
        /// <param name="ar"></param>
        private void UnicastReceiveCallback(IAsyncResult ar)
        {
            if (_running)
            {
                var u = ((UdpState)ar.AsyncState).U;
                var e = ((UdpState)ar.AsyncState).E;
                if (u.Client != null)
                {
                    var responseBytes  = u.EndReceive(ar, ref e);
                    var responseString = Encoding.UTF8.GetString(responseBytes);
                    var httpMatch      = HttpResponseRegex.Match(responseString);
                    if (httpMatch.Success)
                    {
                        responseString = httpMatch.Groups[5].Captures[0].Value;
                        //Logger.Info("Http Response.\r\n\r\n{0} ", responseString);
                        var    headerDictionary = Parse(responseString);
                        string location;
                        headerDictionary.TryGetValue("location", out location);
                        string st;
                        headerDictionary.TryGetValue("st", out st);
                        string usn;
                        headerDictionary.TryGetValue("usn", out usn);
                        string bootId;
                        headerDictionary.TryGetValue("bootid.upnp.org", out bootId);
                        string configId;
                        headerDictionary.TryGetValue("configid.upnp.org", out configId);
                        string deviceId;
                        headerDictionary.TryGetValue("deviceid.ses.com", out deviceId);
                        var m = UuidRegex.Match(usn);
                        if (!m.Success)
                        {
                            return;
                        }
                        var uuid = m.Value;
                        if (!string.IsNullOrEmpty(location) && !string.IsNullOrEmpty(st) &&
                            st.Equals("urn:ses-com:device:SatIPServer:1"))
                        {
                            if (!_devices.ContainsKey(uuid))
                            {
                                var device = new SatIpDevice(location);
                                _devices.Add(uuid, device);
                                OnDeviceFound(new SatIpDeviceFoundArgs(device));
                            }
                        }
                    }
                }

                UnicastSetBeginReceive();
            }
        }
Example #4
0
 /// <summary>
 /// The MulticastReceiveCallback receives M-Search and Notify Responses
 /// M-Search Responses are ignored
 /// Notify Responses fires SatIpDeviceLost Event if nts.Equals(ssdp:byebye) for removing the Device
 /// or SatIpDeviceNotify Event if nts.Equals(ssdp:alive) for inform that the SatIp device is alive
 /// it can be used for initialize a new M-Seach Request too
 /// </summary>
 /// <param name="ar"></param>
 private void MulticastReceiveCallback(IAsyncResult ar)
 {
     if (_running)
     {
         var u = ((UdpState)(ar.AsyncState)).U;
         var e = ((UdpState)(ar.AsyncState)).E;
         if (u.Client != null)
         {
             var responseBytes  = u.EndReceive(ar, ref e);
             var responseString = Encoding.UTF8.GetString(responseBytes);
             var msearchMatch   = MSearchResponseRegex.Match(responseString);
             if (msearchMatch.Success)
             {
                 responseString = msearchMatch.Groups[3].Captures[0].Value;
                 Logger.Info("M-Search Response. \r\n\r\n{0} ", responseString);
                 var    headerDictionary = Parse(responseString);
                 string host;
                 headerDictionary.TryGetValue("host", out host);
                 string man;
                 headerDictionary.TryGetValue("man", out man);
                 string mx;
                 headerDictionary.TryGetValue("mx", out mx);
                 string st;
                 headerDictionary.TryGetValue("st", out st);
             }
             var notifyMatch = NotifyResponseRegex.Match(responseString);
             if (notifyMatch.Success)
             {
                 responseString = notifyMatch.Groups[3].Captures[0].Value;
                 Logger.Info("Notify Response. \r\n\r\n{0} ", responseString);
                 var    headerDictionary = Parse(responseString);
                 string location;
                 headerDictionary.TryGetValue("location", out location);
                 string host;
                 headerDictionary.TryGetValue("host", out host);
                 string nt;
                 headerDictionary.TryGetValue("nt", out nt);
                 string nts;
                 headerDictionary.TryGetValue("nts", out nts);
                 string usn;
                 headerDictionary.TryGetValue("usn", out usn);
                 string bootId;
                 headerDictionary.TryGetValue("bootid.upnp.org", out bootId);
                 string configId;
                 headerDictionary.TryGetValue("configid.upnp.org", out configId);
                 var m = UuidRegex.Match(usn);
                 if (!m.Success)
                 {
                     return;
                 }
                 var uuid = m.Value;
                 if (nts != null &&
                     (nt != null && (nt.Equals("urn:ses-com:device:SatIPServer:1") && nts.Equals("ssdp:byebye"))))
                 {
                     if (usn != null)
                     {
                         if (_devices.ContainsKey(uuid))
                         {
                             _devices.Remove(uuid);
                         }
                         OnDeviceLost(new SatIpDeviceLostArgs(uuid));
                     }
                 }
                 if (nts != null &&
                     (nt != null && (nt.Equals("urn:ses-com:device:SatIPServer:1") && nts.Equals("ssdp:alive"))))
                 {
                     if (!string.IsNullOrEmpty(location))
                     {
                         if (!_devices.ContainsKey(uuid))
                         {
                             var device = new SatIpDevice(location);
                             _devices.Add(uuid, device);
                             OnDeviceFound(new SatIpDeviceFoundArgs(device));
                         }
                     }
                 }
             }
         }
         MulticastSetBeginReceive();
     }
 }
Example #5
0
 public SatIpDeviceFoundArgs(SatIpDevice device)
 {
     Device = device;
 }
Example #6
0
 public CableInformtion(SatIpDevice device)
 {
     InitializeComponent();
     _device = device;
 }
 public SatelliteInformation(SatIpDevice device)
 {
     InitializeComponent();
     _device = device;
 }
 public TerrestrialInformation(SatIpDevice device)
 {
     InitializeComponent();
     _device = device;
 }