示例#1
0
        private void OnRegistrationFieldsResult(object sender, IQ iq, object data)
        {
            if (iq.Type != IqType.error)
            {
                if (iq.Query is Register)
                {
                    RegisterEventArgs args = new RegisterEventArgs(iq.Query as Register);
                    if (OnRegisterInformation != null)
                        OnRegisterInformation(this, args);

                    DoChangeXmppConnectionState(XmppConnectionState.Registering);

                    IQ regIq = new IQ(IqType.set);
                    regIq.GenerateId();
                    regIq.To = new Jid(base.Server);

                    //RegisterIq regIq = new RegisterIq(IqType.set, new Jid(base.Server));
                    if (args.Auto)
                    {
                        Register reg = new Register(this.m_Username, this.m_Password);
                        regIq.Query = reg;
                    }
                    else
                    {
                        regIq.Query = args.Register;
                    }
                    IqGrabber.SendIq(regIq, new IqCB(OnRegisterResult), data);
                }
            }
            else
            {
                if (OnRegisterError != null)
                    OnRegisterError(this, iq);
            }
        }
示例#2
0
        void OnRegistrationFieldsResult(IQEventArgs e, Element data)
        {
            if (e.IQ.Type != IqType.error)
            {
                if (e.IQ.Query is Register)
                {
                    RegisterEventArgs args = new RegisterEventArgs(e.IQ.Query as Register);
                    if (OnRegisterInformation != null)
                        OnRegisterInformation(this, args);

                    DoChangeXmppConnectionState(XmppConnectionState.Registering);

                    IQ regIq = new IQ(IqType.set);
                    regIq.GenerateId();
                    regIq.To = new Jid(base.Server);

                    //RegisterIq regIq = new RegisterIq(IqType.set, new Jid(base.Server));
                    if (args.Auto)
                    {
                        Register reg = new Register(this.m_Username, this.m_Password);
                        regIq.Query = reg;
                    }
                    else
                    {
                        regIq.Query = args.Register;
                    }
                    IqGrabber.SendIq(regIq,
                        (object sender, IQEventArgs ev) => OnRegisterResult(ev, data)
                    );
                    e.Handled = true;
                }
            }
            else
            {
                if (OnRegisterError != null)
                    OnRegisterError(this, e.IQ);
                e.Handled = true; // not really
            }
        }