public static HttpWebRequest CreateSetBinaryStateCommandHttpWebRequest(string ipAddress, string contentType, string soapAction, Soap.WemoSetBinaryStateCommands cmd, string requestMethod) { var req = CreateHttpWebRequest(ipAddress, contentType, soapAction, cmd.ToString(), requestMethod); return(req); }
public async Task <bool> SetBinaryStateAsync(Soap.WemoSetBinaryStateCommands cmd, string ipAddress, bool targetStatus) { bool success = false; var target = Convert.ToInt32(targetStatus); var request = CreateBinaryStateHttpWebRequest(Soap.WemoGetCommands.SetBinaryState, ipAddress); var response = await GetBinaryStateResponseAsync(cmd.ToString(), request, target.ToString()); var responsObj = GetResponseObject <SetBinaryStateResponse>(response); if (responsObj.BinaryState == "0" || responsObj.BinaryState == "1") { success = true; } return(success); }
public async Task <bool> SetBinaryStateAsync(Soap.WemoSetBinaryStateCommands cmd, string ipAddress, bool targetStatus) { bool success = false; var target = Convert.ToInt32(targetStatus); // Construct the HttpWebRequest - if not null we will use the supplied HttpWebRequest object, else create var request = WebRequest ?? HttpRequest.CreateHttpWebRequest($"{ipAddress}:{Port}{Event}", ContentType, SoapAction, "SetBinaryState", RequestMethod); var response = await GetBinaryStateResponseAsync(cmd.ToString(), request, target.ToString()); var responsObj = GetResponseObject <SetBinaryStateResponse>(response); if (responsObj.BinaryState == "0" || responsObj.BinaryState == "1") { success = true; } return(success); }