private void AddPair(RequestResponsePair pair) { if (InvokeRequired) { Invoke(new Action(() => AddPair(pair))); } else { var item = new ListViewItem((lVRequestResponse.Items.Count + 1).ToString(CultureInfo.InvariantCulture)); String status; String details; if (!pair.Request.Validated) { status = "PENDING"; details = String.Empty; } else { status = pair.GetStatusString(); details = pair.Request.GetDetails(); } item.SubItems.Add(status); item.SubItems.Add(details); lVRequestResponse.Items.Add(item); } }
private void AddOpenRequest(Request request) { if (request.HasOption(OptionType.Observe)) { ObservingManager.Instance.AddSubscription(request); } else { if (ObservingManager.Instance.HasSubscription(request.SequenceKey)) { ObservingManager.Instance.CancelSubscription(request.SequenceKey); } RequestResponsePair pair = new RequestResponsePair(); pair.key = request.SequenceKey; pair.request = request; if (log.IsDebugEnabled) { log.Debug("MatchingLayer - Storing open request: " + pair.key); } // FIXME: buggy fix for block transfer in obvervation, since the first request needs to be kept. if (!_pairs.ContainsKey(pair.key))// || !request.IsObserving) { _pairs[pair.key] = pair; } } }
private String GetPairInfo(RequestResponsePair pair) { var conversation = pair.Conversation; int indexOfConversation = ConversationList.GetConversations().IndexOf(conversation) + 1; int indexOfPair = conversation.IndexOf(pair) + 1; return(String.Format("Conversation:{0} - {1} \\ Pair:{2}", indexOfConversation, conversation.Name, indexOfPair)); }
private void AddPair(RequestResponsePair pair) { this.InvokeIfRequired(() => { var item = new ListViewItem((lVRequestResponse.Items.Count + 1).ToString(CultureInfo.InvariantCulture)); var status = pair.GetStatusString(); var details = pair.Request.GetDetails(); item.SubItems.Add(status); item.SubItems.Add(details); lVRequestResponse.Items.Add(item); }); }
public static String GetValidationDetails(this RequestResponsePair pair) { switch (pair.ContentType) { case ContentType.Http: return(GetValidationDetails(pair.GetRequest <HttpRequest>(), pair.GetResponse <HttpResponse>())); case ContentType.Rtsp: return(GetValidationDetails(pair.GetRequest <RtspRequest>(), pair.GetResponse <RtspResponse>())); case ContentType.WSDiscovery: return(String.Empty); default: throw new ArgumentOutOfRangeException("pair.ContentType"); } }
public void Add(RequestResponsePair pair) { if (null == pair) { throw new ArgumentNullException(); } if (null == pair.Response) { pair.SetResponse(new RtspResponse(pair.Conversation)); } mRequestResponseList.Add(pair); if (null != OnPairAdded) { OnPairAdded(this, new ElementEventArgs(mRequestResponseList.Count - 1)); } }
protected override void DoReceiveMessage(Message msg) { if (msg is Response) { Response response = (Response)msg; RequestResponsePair pair = GetOpenRequest(msg.SequenceKey); // check for missing token if (pair == null) { if (msg.IsEmptyACK) { return; } if (response.Token.Length == 0) { if (log.IsInfoEnabled) { log.Info("MatchingLayer - Remote endpoint failed to echo token: " + msg.Key); } // TODO try to recover from peerAddress if (!ObservingManager.Instance.HasSubscription(msg.SequenceKey)) { // also covers CoAP ping SendMessageOverLowerLayer(msg.NewReject()); return; } } else if (ObservingManager.Instance.HasSubscription(msg.SequenceKey)) { Request observeRequest = ObservingManager.Instance.GetSubscriptionRequest(msg.SequenceKey); observeRequest.Response = response; response.Request = observeRequest; } else { if (response.IsConfirmable || response.HasOption(OptionType.Observe)) { if (log.IsInfoEnabled) { log.Info("MatchingLayer - Rejecting unexpected response: " + response.SequenceKey); } SendMessageOverLowerLayer(response.NewReject()); } else { if (log.IsInfoEnabled) { log.Info("MatchingLayer - Dropping unexpected response: " + response.SequenceKey); } } // let timeout handle the problem return; } } else { response.Request = pair.request; pair.request.Response = response; if (log.IsDebugEnabled) { log.Debug("MatchingLayer - Matched open request: " + response.SequenceKey); } // TODO Cancel possible open transaction (note: waiting for stack redesign) if (!msg.IsEmptyACK && msg.GetFirstOption(OptionType.Observe) == null) { RemoveOpenRequest(response.SequenceKey); } } // FIXME accept here but MessageLayer? if (msg.IsConfirmable) { SendMessageOverLowerLayer(msg.NewAccept()); } } DeliverMessage(msg); }
/// <summary> /// Adds a pair to this builder. /// </summary> /// <param name="requestResponsePair">The <see cref="RequestResponsePairs"/> to add.</param> /// <returns>Return this instance of the <see cref="StubServiceBuilder"/> for further customizations.</returns> public StubServiceBuilder AddRequestResponsePair(RequestResponsePair requestResponsePair) { RequestResponsePairs.Add(requestResponsePair); return(this); }
protected override void ProcessConversation(Conversation conversation) { var startStreamingList = conversation.GetMessages(ContentType.Http) .Where(item => item.GetRequest <HttpMessage>().ContainsTag("StartMulticastStreaming")) .ToList(); var stopStreamingList = conversation.GetMessages(ContentType.Http) .Where(item => item.GetRequest <HttpMessage>().ContainsTag("StopMulticastStreaming")) .ToList(); AffectedPairs.AddRange(startStreamingList); AffectedPairs.AddRange(stopStreamingList); bool fS1Printed = false; bool fS1PrintedSOAP = false; bool fS2Printed = false; bool fS3Printed = false; bool fS4Printed = false; bool fS6Printed = false; bool fS6PrintedSOAP = false; bool fS7Printed = false; bool fS8Printed = false; bool fS9Printed = false; int nBestStep = 0; int nBestIdx = 0; List <RequestResponsePair> msgs = conversation.GetMessages(ContentType.Http); int idx = -1; while (idx + 1 < msgs.Count && (idx = msgs.FindIndex(idx + 1, item => ContentType.Http == item.ContentType && item.GetRequest <HttpMessage>().ContainsTag( "StartMulticastStreaming"))) != -1) { if (!fS1Printed) { BeginStep("Client request contains <StartMulticastStreaming> tag", startStreamingList); StepCompleted(); fS1Printed = true; } if (nBestStep == 0) { nBestStep = 1; nBestIdx = idx; } System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.LoadXml(msgs[idx].GetRequest <HttpMessage>().GetXmlString( XmlNamespaceOption.IgnoreNamespaces)); System.Xml.XmlElement docElem = doc.DocumentElement; System.Xml.XmlNode nodeProfileToken = docElem.SelectSingleNode( "Body/StartMulticastStreaming/ProfileToken"); if (nodeProfileToken != null) { if (!fS2Printed) { BeginStep("<StartMulticastStreaming> includes tag " + "<ProfileToken>", startStreamingList); StepCompleted(); fS2Printed = true; } if (nBestStep < 2) { nBestStep = 2; nBestIdx = idx; } if ("200" == msgs[idx].GetResponse <HttpResponse>().StatusCode) { if (!fS3Printed) { BeginStep("Device response contains \"HTTP/* 200 OK\"", startStreamingList, MessageType.Response); StepCompleted(); fS3Printed = true; } if (nBestStep < 3) { nBestStep = 3; nBestIdx = idx; } if (msgs[idx].GetResponse <HttpMessage>().ContainsTag( "StartMulticastStreamingResponse")) { if (!fS4Printed) { BeginStep( "Device response contains " + "<StartMulticastStreamingResponse> tag", startStreamingList, MessageType.Response); StepCompleted(); fS4Printed = true; } if (nBestStep < 4) { nBestStep = 4; nBestIdx = idx; } if (idx + 1 < msgs.Count && ValidationStatus.Failed != msgs[idx + 1].Request.ValidationStatus) { if (msgs[idx + 1].GetRequest <HttpMessage>().ContainsTag( "StopMulticastStreaming")) { if (!fS6Printed) { BeginStep("Client request contains " + "<StopMulticastStreaming> tag", stopStreamingList); StepCompleted(); fS6Printed = true; } if (nBestStep < 6) { nBestStep = 6; nBestIdx = idx; } doc.LoadXml(msgs[idx + 1].GetRequest <HttpMessage>(). GetXmlString(XmlNamespaceOption.IgnoreNamespaces)); docElem = doc.DocumentElement; nodeProfileToken = docElem.SelectSingleNode( "Body/StopMulticastStreaming/ProfileToken"); if (nodeProfileToken != null) { if (!fS7Printed) { BeginStep("<StopMulticastStreaming> includes tag " + "<ProfileToken>", stopStreamingList); StepCompleted(); fS7Printed = true; } if (nBestStep < 7) { nBestStep = 7; nBestIdx = idx; } if ("200" == msgs[idx + 1].GetResponse <HttpResponse>().StatusCode) { if (!fS8Printed) { BeginStep("Device response contains \"HTTP/* 200 OK\"", stopStreamingList, MessageType.Response); StepCompleted(); fS8Printed = true; } if (nBestStep < 8) { nBestStep = 8; nBestIdx = idx; } if (msgs[idx + 1].GetResponse <HttpMessage>().ContainsTag( "StopMulticastStreamingResponse")) { if (!fS9Printed) { BeginStep( "Device response contains " + "<StopMulticastStreamingResponse> tag", stopStreamingList, MessageType.Response); StepCompleted(); fS9Printed = true; } if (nBestStep < 9) { nBestStep = 9; nBestIdx = idx; } break; } } } } } } } } } RequestResponsePair pair = null; if (msgs.Count != 0) { pair = msgs[nBestIdx]; } if (!fS1Printed) { BeginStep("Client request contains <StartMulticastStreaming> tag", startStreamingList); throw new TestNotSupportedException("Conversation does not contain requests with <StartMulticastStreaming> tag"); StepCompleted(); } if (!fS2Printed) { BeginStep("<StartMulticastStreaming> includes tag <ProfileToken>", startStreamingList); StepFailed("<ProfileToken> tag is missing"); StepCompleted(); } if (!fS3Printed) { BeginStep("Device response contains \"HTTP/* 200 OK\"", startStreamingList, MessageType.Response); StepFailed("Response does not contain 200 OK"); StepCompleted(); } if (!fS4Printed) { BeginStep("Device response contains " + "<StartMulticastStreamingResponse> tag", startStreamingList, MessageType.Response); StepFailed("<StartMulticastStreamingResponse> tag is missing"); StepCompleted(); } if (msgs.Count != 0 && nBestIdx + 1 < msgs.Count) { pair = msgs[nBestIdx + 1]; } if (!fS6Printed) { BeginStep("Client request contains " + "<StopMulticastStreaming> tag", stopStreamingList); StepFailed("<StopMulticastStreaming> tag is missing"); StepCompleted(); } if (!fS7Printed) { BeginStep("<StopMulticastStreaming> includes tag " + "<ProfileToken>", stopStreamingList); StepFailed("<ProfileToken> tag is missing"); StepCompleted(); } if (!fS8Printed) { BeginStep("Device response contains \"HTTP/* 200 OK\"", stopStreamingList, MessageType.Response); StepFailed("Response does not contain 200 OK"); StepCompleted(); } if (!fS9Printed) { BeginStep("Device response contains " + "<StopMulticastStreamingResponse> tag", stopStreamingList, MessageType.Response); StepFailed("<StopMulticastStreamingResponse> tag is missing"); StepCompleted(); } }