Ejemplo n.º 1
0
 public void AddDevice(ReplayDevice theDevice)
 {
     bool flag = false;
     bool flag2 = false;
     foreach (ReplayDevice device in this.listReplayDevices)
     {
         if (device.serialNumber == theDevice.serialNumber)
         {
             flag = true;
         }
         if (device.ip == theDevice.ip)
         {
             flag2 = true;
         }
     }
     if (!flag && !flag2)
     {
         this.listReplayDevices.Add(theDevice);
     }
     else
     {
         if (flag)
         {
             throw new DuplicateDeviceException(string.Format("Another device with serial {0} is already listed!", theDevice.serialNumber));
         }
         throw new DuplicateIPException(string.Format("Another device with IP {0} is already listed!", theDevice.ip));
     }
 }
Ejemplo n.º 2
0
        private ReplayDevice ParseRDDNSResponse(byte[] responseContent)
        {
            byte[] bytes = ReplayCrypt.RDDNSDecrypt(responseContent);
            string text  = Encoding.Default.GetString(bytes);

            if (text.IndexOf("ReplayError") >= 0)
            {
                char[]   separator = new char[] { ' ' };
                string[] textArray = text.Split(separator);
                char[]   trimChars = new char[] { '"' };
                this.erRespType = textArray[2].Substring(5).Trim(trimChars);
                char[] chArray3 = new char[] { '"' };
                this.erRespId = textArray[3].Substring(3).Trim(chArray3);
            }
            else
            {
                this.erRespType = "";
                this.erRespId   = "";
            }
            if (text.IndexOf("UnitTicket") >= 0)
            {
                ReplayDevice device     = new ReplayDevice();
                char[]       chArray4   = new char[] { ' ' };
                string[]     textArray2 = text.Split(chArray4);
                char[]       chArray5   = new char[] { '"' };
                device.isn = textArray2[1].Substring(4).Trim(chArray5);
                char[] chArray6 = new char[] { '"' };
                device.ip = textArray2[2].Substring(3).Trim(chArray6);
                char[] chArray7 = new char[] { '"' };
                device.port = textArray2[3].Substring(5).Trim(chArray7);
                return(device);
            }
            return(null);
        }
Ejemplo n.º 3
0
        public void AddDevice(ReplayDevice theDevice)
        {
            bool flag  = false;
            bool flag2 = false;

            foreach (ReplayDevice device in this.listReplayDevices)
            {
                if (device.serialNumber == theDevice.serialNumber)
                {
                    flag = true;
                }
                if (device.ip == theDevice.ip)
                {
                    flag2 = true;
                }
            }
            if (!flag && !flag2)
            {
                this.listReplayDevices.Add(theDevice);
            }
            else
            {
                if (flag)
                {
                    throw new DuplicateDeviceException(string.Format("Another device with serial {0} is already listed!", theDevice.serialNumber));
                }
                throw new DuplicateIPException(string.Format("Another device with IP {0} is already listed!", theDevice.ip));
            }
        }
Ejemplo n.º 4
0
 public string IVSTest(string isn, string responseContentText)
 {
     ReplayDevice device = new ReplayDevice();
     char[] separator = new char[] { ' ' };
     string[] textArray = responseContentText.Split(separator);
     char[] trimChars = new char[] { '"' };
     device.isn = textArray[1].Substring(4).Trim(trimChars);
     char[] chArray3 = new char[] { '"' };
     device.ip = textArray[2].Substring(3).Trim(chArray3);
     char[] chArray4 = new char[] { '"' };
     device.port = textArray[3].Substring(5).Trim(chArray4);
     try
     {
         string xml = HTTPClient.GetAsString("http://" + device.ip + ":" + device.port + "/ivs-IVSGetUnitInfo", 0x3a98);
         XmlDocument document = new XmlDocument();
         document.LoadXml(xml);
         foreach (XmlNode node in document.SelectNodes("/UnitInfo"))
         {
             XmlElement element = node as XmlElement;
             if (element != null)
             {
                 return element.GetAttribute("nickname");
             }
         }
     }
     catch
     {
     }
     return null;
 }
Ejemplo n.º 5
0
        public string GetRemoteIVSName(string remoteISN, string rddnsip)
        {
            string ivsNickname;

            try
            {
                this.remoteDevice = this.RDDNSLookup(remoteISN, false, rddnsip);
            }
            catch
            {
                throw new ApplicationException("Unable to contact RDDNS server.  IVS may be down.");
            }
            if (this.erRespType.Equals("SERVER") && this.erRespId.Equals("-1"))
            {
                throw new ApplicationException("RDDNS lookup failed.  Check your computer's clock.");
            }
            if (this.erRespType.Equals("WORKER") && this.erRespId.Equals("5000"))
            {
                throw new ApplicationException(string.Format("{0} not found on IVS server.", remoteISN));
            }
            if (this.remoteDevice == null)
            {
                throw new ApplicationException(string.Format("{0} not found on IVS server.", remoteISN));
            }
            if (this.remoteDevice.port.Equals("0"))
            {
                throw new ApplicationException("Error: Unable to contact remote ReplayTV using a port of 0.");
            }
            this.remoteDevice.ivsNickname = "n/a";
            try
            {
                string xml = null;
                xml = HTTPClient.GetAsString("http://" + this.remoteDevice.ip + ":" + this.remoteDevice.port + "/ivs-IVSGetUnitInfo");
                XmlDocument document = new XmlDocument();
                document.LoadXml(xml);
                foreach (XmlNode node in document.SelectNodes("/UnitInfo"))
                {
                    XmlElement element = node as XmlElement;
                    if (element != null)
                    {
                        this.remoteDevice.ivsNickname = element.GetAttribute("nickname");
                    }
                }
                ivsNickname = this.remoteDevice.ivsNickname;
            }
            catch
            {
                throw new ApplicationException("Error: Unable to contact remote ReplayTV.");
            }
            return(ivsNickname);
        }
Ejemplo n.º 6
0
 public string GetRemoteIVSName(string remoteISN, string rddnsip)
 {
     string ivsNickname;
     try
     {
         this.remoteDevice = this.RDDNSLookup(remoteISN, false, rddnsip);
     }
     catch
     {
         throw new ApplicationException("Unable to contact RDDNS server.  IVS may be down.");
     }
     if (this.erRespType.Equals("SERVER") && this.erRespId.Equals("-1"))
     {
         throw new ApplicationException("RDDNS lookup failed.  Check your computer's clock.");
     }
     if (this.erRespType.Equals("WORKER") && this.erRespId.Equals("5000"))
     {
         throw new ApplicationException(string.Format("{0} not found on IVS server.", remoteISN));
     }
     if (this.remoteDevice == null)
     {
         throw new ApplicationException(string.Format("{0} not found on IVS server.", remoteISN));
     }
     if (this.remoteDevice.port.Equals("0"))
     {
         throw new ApplicationException("Error: Unable to contact remote ReplayTV using a port of 0.");
     }
     this.remoteDevice.ivsNickname = "n/a";
     try
     {
         string xml = null;
         xml = HTTPClient.GetAsString("http://" + this.remoteDevice.ip + ":" + this.remoteDevice.port + "/ivs-IVSGetUnitInfo");
         XmlDocument document = new XmlDocument();
         document.LoadXml(xml);
         foreach (XmlNode node in document.SelectNodes("/UnitInfo"))
         {
             XmlElement element = node as XmlElement;
             if (element != null)
             {
                 this.remoteDevice.ivsNickname = element.GetAttribute("nickname");
             }
         }
         ivsNickname = this.remoteDevice.ivsNickname;
     }
     catch
     {
         throw new ApplicationException("Error: Unable to contact remote ReplayTV.");
     }
     return ivsNickname;
 }
Ejemplo n.º 7
0
 public void ManualAdd(string ip_address)
 {
     ZoggrLogger.Log("Attempting to manually add a ReplayTV...");
     try
     {
         ReplayDevice theDevice = new ReplayDevice(ip_address, this.options.Options.allowWiRNS);
         this.options.Options.rtvList.AddDevice(theDevice);
         this.options.SaveConfiguration();
         ZoggrLogger.Log(string.Format("Successfully added ReplayTV at {0}.", ip_address));
     }
     catch (Exception exception)
     {
         ZoggrLogger.Log(exception.Message);
     }
 }
Ejemplo n.º 8
0
 public ReplayGuide(ReplayDevice rd)
 {
     this.theDevice = rd;
     this.guideFile = ReplayHelper.MakePathAndFile(this.theDevice.serialNumber + ".guide");
     this.guideXMLFile = ReplayHelper.MakePathAndFile(this.theDevice.serialNumber + ".xml");
     OperatingSystem oSVersion = Environment.OSVersion;
     if (((oSVersion.Platform == PlatformID.Win32NT) || (oSVersion.Platform == PlatformID.Win32S)) || (oSVersion.Platform == PlatformID.Win32Windows))
     {
         ReplayLogger.DebugLog("Using Default Encoding for Windows - " + oSVersion.Platform);
         this.encoding = Encoding.Default;
     }
     else
     {
         ReplayLogger.DebugLog("Request iso-8859-1 Encoding for " + oSVersion.Platform);
         this.encoding = Encoding.GetEncoding("iso-8859-1");
     }
 }
Ejemplo n.º 9
0
        public ReplayGuide(ReplayDevice rd)
        {
            this.theDevice    = rd;
            this.guideFile    = ReplayHelper.MakePathAndFile(this.theDevice.serialNumber + ".guide");
            this.guideXMLFile = ReplayHelper.MakePathAndFile(this.theDevice.serialNumber + ".xml");
            OperatingSystem oSVersion = Environment.OSVersion;

            if (((oSVersion.Platform == PlatformID.Win32NT) || (oSVersion.Platform == PlatformID.Win32S)) || (oSVersion.Platform == PlatformID.Win32Windows))
            {
                ReplayLogger.DebugLog("Using Default Encoding for Windows - " + oSVersion.Platform);
                this.encoding = Encoding.Default;
            }
            else
            {
                ReplayLogger.DebugLog("Request iso-8859-1 Encoding for " + oSVersion.Platform);
                this.encoding = Encoding.GetEncoding("iso-8859-1");
            }
        }
Ejemplo n.º 10
0
        public ReplayDevice RDDNSLookup(string isn, bool final, string rddnsip)
        {
            string requestUri;
            string text2 = ReplayHelper.ByteArrayToHexString(ReplayCrypt.RDDNSEncrypt("isn=" + isn)).ToLower();

            if (rddnsip.Length > 0)
            {
                requestUri = string.Format("http://{0}/rd/servlet/gu?q={1}", rddnsip, text2);
            }
            else
            {
                requestUri = string.Format("http://{0}/rd/servlet/gu?q={1}", rddnsServer, text2);
            }
            byte[]       responseContent = HTTPClient.Get(requestUri);
            ReplayDevice device          = this.ParseRDDNSResponse(responseContent);

            if ((!final && this.erRespType.Equals("SERVER")) && this.erRespId.Equals("-1"))
            {
                device = this.RDDNSLookup(isn, true, rddnsip);
            }
            return(device);
        }
Ejemplo n.º 11
0
 public static SortedList DiscoverRTVs(bool allowWiRNS)
 {
     Socket socket = null;
     SortedList list2;
     try
     {
         SortedList list = new SortedList();
         string s = "M-SEARCH * HTTP/1.1\r\nDate: Fri, 02 Jan 1970 13:53:05 GMT\r\nServer: Unknown/0.0 UPnP/1.0 Virata-EmWeb/R6_0_1\r\nHOST: 239.255.255.250:1900\r\nMAN: ssdp:discover\r\nMX: 10\r\nST: urn:replaytv-com:device:ReplayDevice:1\r\n\r\n";
         socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
         socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 1);
         IPEndPoint localEP = new IPEndPoint(IPAddress.Any, 0);
         socket.Bind(localEP);
         IPEndPoint remoteEP = new IPEndPoint(IPAddress.Parse("239.255.255.250"), 0x76c);
         byte[] bytes = Encoding.ASCII.GetBytes(s);
         socket.SendTo(bytes, remoteEP);
         for (int i = 0; i < 20; i++)
         {
             Thread.Sleep(500);
         }
         IPEndPoint point3 = new IPEndPoint(IPAddress.Any, 0);
         EndPoint point4 = point3;
         byte[] buffer = new byte[0x800];
         while (socket.Poll(0x7a120, SelectMode.SelectRead))
         {
             socket.ReceiveFrom(buffer, 0, buffer.Length, SocketFlags.None, ref point4);
             string text2 = Encoding.ASCII.GetString(buffer, 0, buffer.Length);
             if (text2 != null)
             {
                 int startIndex = text2.ToUpper().IndexOf("LOCATION:");
                 if (startIndex >= 0)
                 {
                     startIndex += 9;
                     int index = text2.IndexOf("\r\n", startIndex);
                     Uri uri = new Uri(text2.Substring(startIndex, index - startIndex).Trim());
                     string ip = uri.Host;
                     try
                     {
                         ReplayDevice device = new ReplayDevice(ip, allowWiRNS);
                         list.Add(ip, device);
                         continue;
                     }
                     catch
                     {
                         continue;
                     }
                 }
             }
         }
         list2 = list;
     }
     catch (Exception exception)
     {
         string message = "Auto-discovery failed!";
         throw new Exception(message, exception);
     }
     finally
     {
         if (socket != null)
         {
             socket.Close();
         }
     }
     return list2;
 }
Ejemplo n.º 12
0
        public int IVSSend5000(string recipientISN, string showID, string rddnsip)
        {
            try
            {
                this.recipientDevice = this.RDDNSLookup(recipientISN, false, rddnsip);
            }
            catch
            {
                throw new ApplicationException("Unable to contact RDDNS server.  IVS may be down.");
            }
            if (this.erRespType.Equals("SERVER") && this.erRespId.Equals("-1"))
            {
                throw new ApplicationException("RDDNS lookup failed.  Check your computer's clock.");
            }
            if (this.erRespType.Equals("WORKER") && this.erRespId.Equals("5000"))
            {
                throw new ApplicationException(string.Format("{0} not found on IVS server.", recipientISN));
            }
            if (this.recipientDevice == null)
            {
                throw new ApplicationException(string.Format("{0} not found on IVS server.", recipientISN));
            }
            IVSInvite5000 structure = new IVSInvite5000();

            structure.unknown1         = IPAddress.HostToNetworkOrder(1);
            structure.unknown2         = IPAddress.HostToNetworkOrder(0);
            structure.unknown3         = IPAddress.HostToNetworkOrder(0);
            structure.unknown4         = IPAddress.HostToNetworkOrder(1);
            structure.isn_field_length = IPAddress.HostToNetworkOrder(0x12);
            structure.recipient_isn    = recipientISN;
            structure.magic1           = IPAddress.HostToNetworkOrder(0);
            structure.magic2           = IPAddress.HostToNetworkOrder(5);
            structure.sender_abe.name  = this.theDevice.ivsNickname;
            byte[] bytes = BitConverter.GetBytes(long.Parse(this.theDevice.isn.Replace("-", "")));
            structure.sender_abe.serial_number = new byte[6];
            if (BitConverter.IsLittleEndian)
            {
                structure.sender_abe.serial_number[0] = bytes[5];
                structure.sender_abe.serial_number[1] = bytes[4];
                structure.sender_abe.serial_number[2] = bytes[3];
                structure.sender_abe.serial_number[3] = bytes[2];
                structure.sender_abe.serial_number[4] = bytes[1];
                structure.sender_abe.serial_number[5] = bytes[0];
            }
            else
            {
                structure.sender_abe.serial_number[0] = bytes[2];
                structure.sender_abe.serial_number[1] = bytes[3];
                structure.sender_abe.serial_number[2] = bytes[4];
                structure.sender_abe.serial_number[3] = bytes[5];
                structure.sender_abe.serial_number[4] = bytes[6];
                structure.sender_abe.serial_number[5] = bytes[7];
            }
            structure.sender_abe.unknown = 0;
            structure.sender_abe.flags   = IPAddress.HostToNetworkOrder(0);
            structure.replay_show        = new byte[0x1ac];
            ReplayGuide guide = new ReplayGuide(this.theDevice);

            Array.Copy(guide.GetReplayShow(Convert.ToInt32(showID)), 0, structure.replay_show, 0, structure.replay_show.Length);
            long host = this.GetFileSize("/Video/" + showID + ".mpg");

            structure.mpeg_size = IPAddress.HostToNetworkOrder(host);
            host = this.GetFileSize("/Video/" + showID + ".ndx");
            structure.index_size = IPAddress.HostToNetworkOrder(host);
            host = this.GetFileSize("/Video/" + showID + ".evt");
            structure.evt_size  = IPAddress.HostToNetworkOrder(host);
            structure.reserved1 = new byte[0x2c];
            structure.reserved2 = new byte[8];
            structure.reserved3 = new byte[8];
            IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(structure));

            Marshal.StructureToPtr(structure, ptr, true);
            if (ptr == IntPtr.Zero)
            {
                return(1);
            }
            byte[] destination = new byte[Marshal.SizeOf(structure)];
            Marshal.Copy(ptr, destination, 0, destination.Length);
            string text     = ReplayHelper.ByteArrayToHexString(destination).ToUpper();
            string asString = HTTPClient.GetAsString(string.Concat(new object[] { "http://", this.recipientDevice.ip, ":", this.recipientDevice.port, "/ivs-IVSSendNotification?isn=", recipientISN, "&size=", text.Length, "&data=", text }));

            if (asString == "0x9478001e")
            {
                throw new ApplicationException(string.Format("Remote ReplayTV is blocking sends from {0}.  Unable to send show!", this.theDevice.ivsNickname));
            }
            if (asString != "0x00000000")
            {
                throw new ApplicationException("Unable to contact remote ReplayTV");
            }
            return(0);
        }
Ejemplo n.º 13
0
 private ReplayDevice ParseRDDNSResponse(byte[] responseContent)
 {
     byte[] bytes = ReplayCrypt.RDDNSDecrypt(responseContent);
     string text = Encoding.Default.GetString(bytes);
     if (text.IndexOf("ReplayError") >= 0)
     {
         char[] separator = new char[] { ' ' };
         string[] textArray = text.Split(separator);
         char[] trimChars = new char[] { '"' };
         this.erRespType = textArray[2].Substring(5).Trim(trimChars);
         char[] chArray3 = new char[] { '"' };
         this.erRespId = textArray[3].Substring(3).Trim(chArray3);
     }
     else
     {
         this.erRespType = "";
         this.erRespId = "";
     }
     if (text.IndexOf("UnitTicket") >= 0)
     {
         ReplayDevice device = new ReplayDevice();
         char[] chArray4 = new char[] { ' ' };
         string[] textArray2 = text.Split(chArray4);
         char[] chArray5 = new char[] { '"' };
         device.isn = textArray2[1].Substring(4).Trim(chArray5);
         char[] chArray6 = new char[] { '"' };
         device.ip = textArray2[2].Substring(3).Trim(chArray6);
         char[] chArray7 = new char[] { '"' };
         device.port = textArray2[3].Substring(5).Trim(chArray7);
         return device;
     }
     return null;
 }
Ejemplo n.º 14
0
 public ReplayClient(ReplayDevice re)
 {
     this.theDevice = re;
     this.guideFile = ReplayHelper.MakePathAndFile(this.theDevice.serialNumber + ".guide");
 }
Ejemplo n.º 15
0
 public int IVSSend5000(string recipientISN, string showID, string rddnsip)
 {
     try
     {
         this.recipientDevice = this.RDDNSLookup(recipientISN, false, rddnsip);
     }
     catch
     {
         throw new ApplicationException("Unable to contact RDDNS server.  IVS may be down.");
     }
     if (this.erRespType.Equals("SERVER") && this.erRespId.Equals("-1"))
     {
         throw new ApplicationException("RDDNS lookup failed.  Check your computer's clock.");
     }
     if (this.erRespType.Equals("WORKER") && this.erRespId.Equals("5000"))
     {
         throw new ApplicationException(string.Format("{0} not found on IVS server.", recipientISN));
     }
     if (this.recipientDevice == null)
     {
         throw new ApplicationException(string.Format("{0} not found on IVS server.", recipientISN));
     }
     IVSInvite5000 structure = new IVSInvite5000();
     structure.unknown1 = IPAddress.HostToNetworkOrder(1);
     structure.unknown2 = IPAddress.HostToNetworkOrder(0);
     structure.unknown3 = IPAddress.HostToNetworkOrder(0);
     structure.unknown4 = IPAddress.HostToNetworkOrder(1);
     structure.isn_field_length = IPAddress.HostToNetworkOrder(0x12);
     structure.recipient_isn = recipientISN;
     structure.magic1 = IPAddress.HostToNetworkOrder(0);
     structure.magic2 = IPAddress.HostToNetworkOrder(5);
     structure.sender_abe.name = this.theDevice.ivsNickname;
     byte[] bytes = BitConverter.GetBytes(long.Parse(this.theDevice.isn.Replace("-", "")));
     structure.sender_abe.serial_number = new byte[6];
     if (BitConverter.IsLittleEndian)
     {
         structure.sender_abe.serial_number[0] = bytes[5];
         structure.sender_abe.serial_number[1] = bytes[4];
         structure.sender_abe.serial_number[2] = bytes[3];
         structure.sender_abe.serial_number[3] = bytes[2];
         structure.sender_abe.serial_number[4] = bytes[1];
         structure.sender_abe.serial_number[5] = bytes[0];
     }
     else
     {
         structure.sender_abe.serial_number[0] = bytes[2];
         structure.sender_abe.serial_number[1] = bytes[3];
         structure.sender_abe.serial_number[2] = bytes[4];
         structure.sender_abe.serial_number[3] = bytes[5];
         structure.sender_abe.serial_number[4] = bytes[6];
         structure.sender_abe.serial_number[5] = bytes[7];
     }
     structure.sender_abe.unknown = 0;
     structure.sender_abe.flags = IPAddress.HostToNetworkOrder(0);
     structure.replay_show = new byte[0x1ac];
     ReplayGuide guide = new ReplayGuide(this.theDevice);
     Array.Copy(guide.GetReplayShow(Convert.ToInt32(showID)), 0, structure.replay_show, 0, structure.replay_show.Length);
     long host = this.GetFileSize("/Video/" + showID + ".mpg");
     structure.mpeg_size = IPAddress.HostToNetworkOrder(host);
     host = this.GetFileSize("/Video/" + showID + ".ndx");
     structure.index_size = IPAddress.HostToNetworkOrder(host);
     host = this.GetFileSize("/Video/" + showID + ".evt");
     structure.evt_size = IPAddress.HostToNetworkOrder(host);
     structure.reserved1 = new byte[0x2c];
     structure.reserved2 = new byte[8];
     structure.reserved3 = new byte[8];
     IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(structure));
     Marshal.StructureToPtr(structure, ptr, true);
     if (ptr == IntPtr.Zero)
     {
         return 1;
     }
     byte[] destination = new byte[Marshal.SizeOf(structure)];
     Marshal.Copy(ptr, destination, 0, destination.Length);
     string text = ReplayHelper.ByteArrayToHexString(destination).ToUpper();
     string asString = HTTPClient.GetAsString(string.Concat(new object[] { "http://", this.recipientDevice.ip, ":", this.recipientDevice.port, "/ivs-IVSSendNotification?isn=", recipientISN, "&size=", text.Length, "&data=", text }));
     if (asString == "0x9478001e")
     {
         throw new ApplicationException(string.Format("Remote ReplayTV is blocking sends from {0}.  Unable to send show!", this.theDevice.ivsNickname));
     }
     if (asString != "0x00000000")
     {
         throw new ApplicationException("Unable to contact remote ReplayTV");
     }
     return 0;
 }
Ejemplo n.º 16
0
        public static SortedList DiscoverRTVs(bool allowWiRNS)
        {
            Socket     socket = null;
            SortedList list2;

            try
            {
                SortedList list = new SortedList();
                string     s    = "M-SEARCH * HTTP/1.1\r\nDate: Fri, 02 Jan 1970 13:53:05 GMT\r\nServer: Unknown/0.0 UPnP/1.0 Virata-EmWeb/R6_0_1\r\nHOST: 239.255.255.250:1900\r\nMAN: ssdp:discover\r\nMX: 10\r\nST: urn:replaytv-com:device:ReplayDevice:1\r\n\r\n";
                socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
                socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 1);
                IPEndPoint localEP = new IPEndPoint(IPAddress.Any, 0);
                socket.Bind(localEP);
                IPEndPoint remoteEP = new IPEndPoint(IPAddress.Parse("239.255.255.250"), 0x76c);
                byte[]     bytes    = Encoding.ASCII.GetBytes(s);
                socket.SendTo(bytes, remoteEP);
                for (int i = 0; i < 20; i++)
                {
                    Thread.Sleep(500);
                }
                IPEndPoint point3 = new IPEndPoint(IPAddress.Any, 0);
                EndPoint   point4 = point3;
                byte[]     buffer = new byte[0x800];
                while (socket.Poll(0x7a120, SelectMode.SelectRead))
                {
                    socket.ReceiveFrom(buffer, 0, buffer.Length, SocketFlags.None, ref point4);
                    string text2 = Encoding.ASCII.GetString(buffer, 0, buffer.Length);
                    if (text2 != null)
                    {
                        int startIndex = text2.ToUpper().IndexOf("LOCATION:");
                        if (startIndex >= 0)
                        {
                            startIndex += 9;
                            int    index = text2.IndexOf("\r\n", startIndex);
                            Uri    uri   = new Uri(text2.Substring(startIndex, index - startIndex).Trim());
                            string ip    = uri.Host;
                            try
                            {
                                ReplayDevice device = new ReplayDevice(ip, allowWiRNS);
                                list.Add(ip, device);
                                continue;
                            }
                            catch
                            {
                                continue;
                            }
                        }
                    }
                }
                list2 = list;
            }
            catch (Exception exception)
            {
                string message = "Auto-discovery failed!";
                throw new Exception(message, exception);
            }
            finally
            {
                if (socket != null)
                {
                    socket.Close();
                }
            }
            return(list2);
        }
Ejemplo n.º 17
0
 public ReplayClient(ReplayDevice re)
 {
     this.theDevice = re;
     this.guideFile = ReplayHelper.MakePathAndFile(this.theDevice.serialNumber + ".guide");
 }