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


C# agsXMPP.GetType方法代码示例

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


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

示例1: OnStreamElement

        internal void OnStreamElement(object sender, agsXMPP.Xml.Dom.Node e)
        {
            if ( m_XmppClient.XmppConnectionState == XmppConnectionState.Securing
                || m_XmppClient.XmppConnectionState == XmppConnectionState.StartCompression)
                return;

            if ( e.GetType() == typeof(protocol.stream.Features) )
            {
                Features f = e as Features;
                if (!m_XmppClient.Authenticated)
                {
                    // RECV: <stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
                    //			<mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism>
                    //			</mechanisms>
                    //			<register xmlns='http://jabber.org/features/iq-register'/>
                    //		</stream:features>
                    // SENT: <auth mechanism="DIGEST-MD5" xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>
                    // Select a SASL mechanism

                    SaslEventArgs args = new SaslEventArgs(f.Mechanisms);

                    if (OnSaslStart != null)
                        OnSaslStart(this, args);

                    if (args.Auto == true)
                    {
                        // Library handles the Sasl stuff
                        if (f.Mechanisms!=null)
                        {
                            if (m_XmppClient.UseStartTLS == false && m_XmppClient.UseSSL == false
                                && f.Mechanisms.SupportsMechanism(MechanismType.X_GOOGLE_TOKEN) )
                            {
                                // This is the only way to connect to GTalk on a unsecure Socket for now
                                // Secure authentication is done over https requests to pass the
                                // authentication credentials on a secure connection
                                args.Mechanism = agsXMPP.protocol.sasl.Mechanism.GetMechanismName(MechanismType.X_GOOGLE_TOKEN);
                            }
                            else if (f.Mechanisms.SupportsMechanism(MechanismType.DIGEST_MD5))
                            {
                                args.Mechanism = agsXMPP.protocol.sasl.Mechanism.GetMechanismName(MechanismType.DIGEST_MD5);
                            }
                            else if (f.Mechanisms.SupportsMechanism(MechanismType.PLAIN))
                            {
                                args.Mechanism = agsXMPP.protocol.sasl.Mechanism.GetMechanismName(MechanismType.PLAIN);
                            }
                            else
                            {
                                args.Mechanism = null;
                            }
                        }
                        else
                        {
                            // Hack for Google
                            // TODO: i don't think we need this anymore. This was in an very early version of the gtalk server.
                            args.Mechanism = null;
                            //args.Mechanism = agsXMPP.protocol.sasl.Mechanism.GetMechanismName(agsXMPP.protocol.sasl.MechanismType.PLAIN);
                        }
                    }
                    if (args.Mechanism != null)
                    {
                        m_Mechanism = Factory.SaslFactory.GetMechanism(args.Mechanism);
                        // Set properties for the SASL mechanism
                        m_Mechanism.Username = m_XmppClient.Username;
                        m_Mechanism.Password = m_XmppClient.Password;
                        m_Mechanism.Server = m_XmppClient.Server;
                        // Call Init Method on the mechanism
                        m_Mechanism.Init(m_XmppClient);
                    }
                    else
                    {
                        m_XmppClient.RequestLoginInfo();
                    }
                }
                else if(!m_XmppClient.Binded)
                {
                    if (f.SupportsBind)
                    {
                        m_XmppClient.DoChangeXmppConnectionState(XmppConnectionState.Binding);

                        BindIq bIq;
                        if (m_XmppClient.Resource == null || m_XmppClient.Resource.Length == 0)
                            bIq = new BindIq(IqType.set, new Jid(m_XmppClient.Server));
                        else
                            bIq = new BindIq(IqType.set, new Jid(m_XmppClient.Server), m_XmppClient.Resource);

                        m_XmppClient.IqGrabber.SendIq(bIq, new IqCB(BindResult), null);
                    }
                }

            }
            else if ( e.GetType() == typeof(protocol.sasl.Challenge) )
            {
                if (m_Mechanism != null && !m_XmppClient.Authenticated)
                {
                    m_Mechanism.Parse(e);
                }
            }
            else if ( e.GetType() == typeof(protocol.sasl.Success) )
            {
                // SASL authentication was successfull
//.........这里部分代码省略.........
开发者ID:wraithkings,项目名称:wmtalk,代码行数:101,代码来源:SaslHandler.cs


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