/// <summary> /// This method sends a echo message and waits for a response. /// </summary> /// <param name="message">The message.</param> /// <param name="timeoutMilliseconds">The timeout in milliseconds.</param> /// <returns>The echo.</returns> public string CallEcho(string message, uint timeoutMilliseconds) { // method entry log message // this.log.Trace("CallEcho(...) - running..."); // start stop watch for execution time measurement var executionTimeStopWatch = new Stopwatch(); executionTimeStopWatch.Start(); // create string for response var response = new StringBuilder(); // clear list of echo messages this.pushMessageProcessor.GetEchoMessages(); // create uri var uri = this.uriCreator.GetAppComInterfaceUri(); // create message var appComMessage = RequestCreator.CreateCallEchoRequest(message); // send message this.appComProtocolLayer.Post(uri.ToString(), appComMessage); // wait for answer var stopWatch = new Stopwatch(); stopWatch.Start(); var succeed = false; var done = false; while (!done) { if (stopWatch.ElapsedMilliseconds > timeoutMilliseconds) { done = true; } else { Thread.Sleep(WaitForEchoResponsePeriodMs); var newMessages = this.pushMessageProcessor.GetEchoMessages(); foreach (var newMessage in newMessages) { response.Append(newMessage); } if (newMessages.Length > 0) { done = true; succeed = true; } } } if (!succeed) { // this.log.Info("Timeout"); throw new TDDException("Timeout"); } // method exit log message // this.log.Debug("CallEcho(...) - duration = {0} ms", executionTimeStopWatch.ElapsedMilliseconds); // this.log.Trace("CallEcho(...) - done"); return(response.ToString()); }