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


C# IQ.SelectSingleElement方法代码示例

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


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

示例1: BindResult

        /// <summary>
        /// </summary>
        /// <param name="sender">
        /// </param>
        /// <param name="iq">
        /// </param>
        /// <param name="data">
        /// </param>
        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, new IqCB(SessionResult), null);
            }
            else if (iq.Type == IqType.error)
            {
                // TODO, handle bind errors
            }
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:48,代码来源:SaslHandler.cs

示例2: OnBrowseIQ

 private void OnBrowseIQ(object sender, IQ iq, object data)
 {
     Element element = iq.SelectSingleElement(typeof(Service));
     if (element != null)
     {
         string[] namespaces = (element as Service).GetNamespaces();
     }
 }
开发者ID:vanloc0301,项目名称:mychongchong,代码行数:8,代码来源:frmMain.cs


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