protected void ProcessQueuedResponses(XmlStream xml, CancellationToken canceltoken) { InfoQueryResponse iq; while (!canceltoken.IsCancellationRequested && QueuedResponses.TryDequeue(out iq)) { iq.Query.Callback(iq, canceltoken); } canceltoken.ThrowIfCancellationRequested(); }
protected void EnqueueInfoQueryResponse(XElement iq) { InfoQuery query = RunningQueries[iq.Attribute("id").Value]; string type = iq.Attribute("type").Value; XAttribute from = iq.Attribute("from"); XAttribute to = iq.Attribute("to"); IEnumerable <XElement> error = iq.Elements(NamespaceClient + "error"); IEnumerable <XElement> content = iq.Elements().Where(el => el.Name != (NamespaceClient + "error")); QueuedResponses.Enqueue( new InfoQueryResponse { Query = query, Type = type, From = from == null ? null : from.Value, To = to == null ? null : to.Value, Content = content, Error = error, IQElement = iq } ); ResponsesQueued.Set(); }