コード例 #1
0
ファイル: Communication.cs プロジェクト: rusdady/YamahaRCLib
        /// <summary>
        /// Method implements initial request. Returned result sets to Atomics.UnitDescription property and
        /// to internal this._xmlDescription variable.
        /// </summary>
        /// <param name="hostNameorAddress">Host name or IP address of the AV receiver</param>
        public bool RequestUnitDescription(string hostNameorAddress)
        {
            Atomics.HostNameOrIPAddress = hostNameorAddress;

            bool result = false;

            try
            {
                if (PingIpAddress(3, hostNameorAddress) == true)
                {
                    string ynccmd = YNCCommand.CreateCommand(MethodType.NONE);

                    Atomics.UnitDescription = Http.Send(hostNameorAddress, Atomics.UnitDescriptionPath, HttpMethod.Get, ynccmd);
                    UnitDescription         = Atomics.UnitDescription;
                    OnResponseReceived?.Invoke(this, new CommEventArgs()
                    {
                        Success = true, UnitDescription = Atomics.UnitDescription, YNCFunction = CommandListFunctionType.UnitDescription
                    });

                    result = true;
                }
                else
                {
                    throw new Exception("Receiver is not accessible.");
                }
            }
            catch (Exception ex)
            {
                OnResponseReceived?.Invoke(this, new CommEventArgs()
                {
                    Success = false, ErrorMessage = ex.Message, YNCFunction = CommandListFunctionType.UnitDescription
                });
            }

            return(result);
        }
コード例 #2
0
ファイル: Communication.cs プロジェクト: rusdady/YamahaRCLib
        /// <summary>
        /// Method creates YNC command, sends it to AV unit, and returns response
        /// </summary>
        /// <param name="cmd">YNCCommand.CommandType type</param>
        /// <param name="path">Sequential presentation of YNC function: System,Misc,Network,Network_Name</param>
        /// <returns>XElement response</returns>
        internal XElement SendYNCCommand(MethodType cmd, string path, object value = null)
        {
            string ynccmd = YNCCommand.CreateCommand(cmd, path, value);

            return(Http.Send(Atomics.HostNameOrIPAddress, Atomics.RemoteControlPath, YamahaAVLib.ENums.HttpMethod.Post, ynccmd));
        }