Пример #1
0
        protected void ProcessQueuedResponses(XmlStream xml, CancellationToken canceltoken)
        {
            InfoQueryResponse iq;

            while (!canceltoken.IsCancellationRequested && QueuedResponses.TryDequeue(out iq))
            {
                iq.Query.Callback(iq, canceltoken);
            }

            canceltoken.ThrowIfCancellationRequested();
        }
Пример #2
0
        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();
        }