当前位置: 首页>>代码示例>>C#>>正文


C# IQ.SelectSingleElement方法代码示例

本文整理汇总了C#中agsXMPP.protocol.client.IQ.SelectSingleElement方法的典型用法代码示例。如果您正苦于以下问题:C# IQ.SelectSingleElement方法的具体用法?C# IQ.SelectSingleElement怎么用?C# IQ.SelectSingleElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在agsXMPP.protocol.client.IQ的用法示例。


在下文中一共展示了IQ.SelectSingleElement方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FileTransfer

        public FileTransfer(XmppClientConnection xmppCon, IQ iq, IContact from)
            : base(from)
        {
            _siIq = iq;
            _si = iq.SelectSingleElement(typeof (SI)) as SI;

            if (_si != null)
            {
                // get SID for file transfer
                _sid = _si.Id;
                _file = _si.File;

                Contact = from;

                if (_file != null)
                {
                    _fileLength = _file.Size;

                    FileDescription = _file.Description;
                    FileName = _file.Name;
                }

                _xmppConnection = xmppCon;
            }
        }
开发者ID:erpframework,项目名称:xeus-messenger2,代码行数:25,代码来源:FileTransfer.cs

示例2: frmFileTransfer

        public frmFileTransfer(XmppClientConnection XmppCon, IQ iq)
        {
            InitializeComponent();
            cmdSend.Enabled = false;
            this.Text = "Receive File from " + iq.From.ToString();

            siIq = iq;
            si = iq.SelectSingleElement(typeof(agsXMPP.protocol.extensions.si.SI)) as agsXMPP.protocol.extensions.si.SI;
            // get SID for file transfer
            m_Sid = si.Id;
            m_From = iq.From;

            file = si.File;

            if (file != null)
            {
                m_lFileLength = file.Size;

                this.lblDescription.Text    = file.Description;
                this.lblFileName.Text       = file.Name;
                this.lblFileSize.Text       = HRSize(m_lFileLength);
                this.txtDescription.Visible = false;
            }

            m_XmppCon = XmppCon;

            this.progress.Maximum = 100;
            //this.Text += iq.From.ToString();

            //this.tbFileSize.Text = FileTransferUtils.ConvertToByteString(m_lFileLength);

            XmppCon.OnIq += new IqHandler(XmppCon_OnIq);
        }
开发者ID:phiree,项目名称:dzdocs,代码行数:33,代码来源:frmFileTransfer.cs

示例3: EventInfoFileTransfer

        public EventInfoFileTransfer(IQ iq)
            : base(string.Empty, EventSeverity.Info)
        {
            _iq = iq;

            agsXMPP.protocol.extensions.si.SI si = iq.SelectSingleElement(typeof(agsXMPP.protocol.extensions.si.SI)) as agsXMPP.protocol.extensions.si.SI;

            if (si != null)
            {
                _file = si.File;

                _contact = Roster.Instance.FindContactOrGetNew(iq.From);
            }

            _message = string.Format("Incoming file '{0}' from {1}", FileName, Contact.DisplayName);
        }
开发者ID:erpframework,项目名称:xeus-messenger2,代码行数:16,代码来源:EventInfoFileTransfer.cs

示例4: OnIqResponseHandler

        /// <summary>
        ///     Lookup the TaskCompletionSource for the IQ message and try to set the result.
        /// </summary>
        /// <param name="sender">object</param>
        /// <param name="iq">IQ</param>
        private void OnIqResponseHandler(object sender, IQ iq)
        {
            Debug.WriteLine("Received event " + iq.Id);
            Debug.WriteLine(iq.ToString());
            TaskCompletionSource<IQ> resulTaskCompletionSource;
            if ((iq.Id != null) && _resultTaskCompletionSources.TryGetValue(iq.Id, out resulTaskCompletionSource))
            {
                // Error handling from XMPP
                if (iq.Error != null)
                {
                    var errorMessage = iq.Error.ErrorText;
                    Debug.WriteLine(errorMessage);
                    resulTaskCompletionSource.TrySetException(new Exception(errorMessage));
                    // Result task is longer needed in the lookup
                    _resultTaskCompletionSources.Remove(iq.Id);
                    return;
                }

                // Message processing (error handling)
                if (iq.HasTag("oa"))
                {
                    var oaElement = iq.SelectSingleElement("oa");

                    // Check error code
                    var errorCode = oaElement.GetAttribute("errorcode");
                    // 100 -> continue
                    if ("100".Equals(errorCode))
                    {
                        // Ignoring 100 continue
                        Debug.WriteLine("Ignoring, expecting more to come.");

                        // TODO: Insert code to handle progress updates for the startActivity
                    }
                    // 200 -> OK
                    else if ("200".Equals(errorCode))
                    {
                        resulTaskCompletionSource.TrySetResult(iq);

                        // Result task is longer needed in the lookup
                        _resultTaskCompletionSources.Remove(iq.Id);
                    }
                    else
                    {
                        // We didn't get a 100 or 200, this must mean there was an error
                        var errorMessage = oaElement.GetAttribute("errorstring");
                        Debug.WriteLine(errorMessage);
                        // Set the exception on the TaskCompletionSource, it will be picked up in the await
                        resulTaskCompletionSource.TrySetException(new Exception(errorMessage));

                        // Result task is longer needed in the lookup
                        _resultTaskCompletionSources.Remove(iq.Id);
                    }
                }
                else
                {
                    Debug.WriteLine("Unexpected content");
                }
            }
            else
            {
                Debug.WriteLine("No matching result task found.");
            }
        }
开发者ID:Lakritzator,项目名称:harmony,代码行数:68,代码来源:HarmonyClient.cs

示例5: GetData

 /// <summary>
 ///     Get the data from the IQ response object
 /// </summary>
 /// <param name="iq">IQ response object</param>
 /// <returns>string with the data of the element</returns>
 private string GetData(IQ iq)
 {
     if (iq.HasTag("oa"))
     {
         var oaElement = iq.SelectSingleElement("oa");
         // Keep receiving messages until we get a 200 status
         // Activity commands send 100 (continue) until they finish
         var errorCode = oaElement.GetAttribute("errorcode");
         if ("200".Equals(errorCode))
         {
             return oaElement.GetData();
         }
     }
     return null;
 }
开发者ID:Lakritzator,项目名称:harmony,代码行数:20,代码来源:HarmonyClient.cs

示例6: SiIqResult

        private void SiIqResult(object sender, IQ iq, object data)
        {
            // Parse the result of the form
            if (iq.Type == IqType.result)
            {
                SI si = iq.SelectSingleElement(typeof (SI)) as SI;
                if (si != null)
                {
                    FeatureNeg fNeg = si.FeatureNeg;
                    if (SelectedByteStream(fNeg))
                    {
                        DiscoProxy();
                    }
                }
            }
            else if (iq.Type == IqType.error)
            {
                Error err = iq.Error;
                if (err != null)
                {
                    switch ((int) err.Code)
                    {
                        case 403:
                            State = FileTransferState.Cancelled;
                            break;
                        default:
                            State = FileTransferState.Cancelled;
                            break;
                    }
                }

                OnTransferFinish(this);
            }
        }
开发者ID:erpframework,项目名称:xeus-messenger2,代码行数:34,代码来源:FileTransfer.cs

示例7: OnBrowseIQ

 private void OnBrowseIQ(object sender, IQ iq, object data)
 {
     Element s = iq.SelectSingleElement(typeof(agsXMPP.protocol.iq.browse.Service));
     if (s != null)
     {
         agsXMPP.protocol.iq.browse.Service service = s as agsXMPP.protocol.iq.browse.Service;
         string[] ns = service.GetNamespaces();
     }
 }
开发者ID:koralarts,项目名称:HipsterChat,代码行数:9,代码来源:frmMain.cs

示例8: SiIqResult

 private void SiIqResult(object sender, IQ iq, object data)
 {
     // Parse the result of the form
     if (iq.Type == IqType.result)
     {
         // <iq xmlns="jabber:client" id="aab4a" to="[email protected]/Psi" type="result"><si
         // xmlns="http://jabber.org/protocol/si" id="s5b_405645b6f2b7c681"><feature
         // xmlns="http://jabber.org/protocol/feature-neg"><x xmlns="jabber:x:data" type="submit"><field
         // var="stream-
         // method"><value>http://jabber.org/protocol/bytestreams</value></field></x></feature></si></iq>
         SI si = iq.SelectSingleElement(typeof(SI)) as SI;
         if (si != null)
         {
             FeatureNeg fNeg = si.FeatureNeg;
             if ( SelectedByteStream(fNeg) )
             {
                 SendStreamHosts();
             }
         }
     }
     else if(iq.Type == IqType.error)
     {
         agsXMPP.protocol.client.Error err = iq.Error;
         if (err != null)
         {
             switch ((int) err.Code)
             {
                 case 403:
                     MessageBox.Show("The file was rejected by the remote user", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     break;
             }
         }
     }
 }
开发者ID:phiree,项目名称:dzdocs,代码行数:34,代码来源:frmFileTransfer.cs

示例9: BindResult

        private void BindResult(object sender, IQ iq, object data)
        {
            // Once the server has generated a resource identifier for the client or accepted the resource
            // identifier provided by the client, it MUST return an IQ stanza of type "result"
            // to the client, which MUST include a <jid/> child element that specifies the full JID for
            // the connected resource as determined by the server:

            // Server informs client of successful resource binding:
            // <iq type='result' id='bind_2'>
            //  <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
            //    <jid>[email protected]/someresource</jid>
            //  </bind>
            // </iq>
            if (iq.Type == IqType.result)
            {
                // i assume the server could assign another resource here to the client
                // so grep the resource assigned by the server now
                Element bind = iq.SelectSingleElement(typeof(Bind));
                if (bind != null)
                {
                    Jid jid = ((Bind)bind).Jid;
                    m_XmppClient.Resource = jid.Resource;
                    m_XmppClient.Username = jid.User;
                }

                m_XmppClient.DoChangeXmppConnectionState(XmppConnectionState.Binded);
                m_XmppClient.m_Binded = true;

                m_XmppClient.DoRaiseEventBinded();

                // success, so start the session now
                m_XmppClient.DoChangeXmppConnectionState(XmppConnectionState.StartSession);
                SessionIq sIq = new SessionIq(IqType.set, new Jid(m_XmppClient.Server));
                m_XmppClient.IqGrabber.SendIq(sIq, SessionResult, null);

            }
            else if (iq.Type == IqType.error)
            {
                // TODO, handle bind errors
                m_XmppClient.DoRaiseEventBindError(iq);
            }
        }
开发者ID:sjkp,项目名称:agsxmpp,代码行数:42,代码来源:SaslHandler.cs


注:本文中的agsXMPP.protocol.client.IQ.SelectSingleElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。