public void Register(string username, string password,string email)
 {
     agsXMPP.protocol.iq.register.Register resgiterItem = new agsXMPP.protocol.iq.register.Register(username, password);
     resgiterItem.Email = email;
     agsXMPP.protocol.iq.register.RegisterIq r = new agsXMPP.protocol.iq.register.RegisterIq();
     _connection.Open(username, password);
 }
示例#2
0
            //客户端发送一个注册新用户的请求
            //<iq id='uid1' type='get'>
            //    <query xmlns='jabber:iq:register'/>
            //</iq>

            //服务器返回注册用户时,所要用到的字段,和注册提示信息
            //<iq xmlns='jabber:client' id='uid1' type='result'>
            //    <query xmlns='jabber:iq:register'>
            //        <username/>
            //        <password/>
            //        <instructions>Enter a username and password to register with this server.</instructions>
            //    </query>
            //</iq>

            //客户端按服务器的要求,发送注册信息
            //<iq id='uid2' type='set'>
            //    <query xmlns='jabber:iq:register'>
            //        <username>test3</username>
            //        <password>1234</password>
            //    </query>
            //</iq>

            //服务器返回注册结果
            //<iq xmlns='jabber:client' id='uid2' type='result'/>
            private void ProcessRegisterIQ(IQ iq)
            {
                if (iq.Type == IqType.get)
                {
                    agsXMPP.protocol.iq.register.RegisterIq registerIq = new agsXMPP.protocol.iq.register.RegisterIq(IqType.result);
                    registerIq.Namespace = agsXMPP.Uri.CLIENT;
                    registerIq.Id = iq.Id;

                    //***********************************
                    registerIq.Query.SetTag("CompanyID");
                    registerIq.Query.SetTag("CompanyName");
                    registerIq.Query.SetTag("UserID");
                    //***********************************

                    registerIq.Query.Username = string.Empty;
                    registerIq.Query.Password = string.Empty;

                    //***********************************
                    registerIq.Query.SetTag("Role");
                    registerIq.Query.SetTag("Group");
                    registerIq.Query.SetTag("Privilege");
                    //***********************************

                    registerIq.Query.Instructions = "Enter a username and password to register with this server.";

                    Send(registerIq);

                }
                else if (iq.Type == IqType.set)
                {
                    IQ newIq = new IQ(IqType.result);
                    newIq.Namespace = agsXMPP.Uri.CLIENT;
                    newIq.Id = iq.Id;

                    agsXMPP.protocol.iq.register.Register register = iq.Query as agsXMPP.protocol.iq.register.Register;

                    //***********************************
                    string strCompanyName = register.GetTag("CompanyName");
                    string strCompanyID = register.GetTag("CompanyID");
                    string strUserID = register.GetTag("UserID");
                    //***********************************

                    string strUserName = register.Username;
                    string strPassword = register.Password;

                    //***********************************
                    string strRole = register.GetTag("Role");
                    //string strGroup = register.GetTag("Group");
                    string strPrivilege = register.GetTag("Privilege");
                    //***********************************

                    Account account = this.m_Server.AccountManager.AddAccount();

                    ///************************************************************
                    ///决定在哪个Sub服务器中注册当前账号,此选项为Super服务器路由用
                    ///************************************************************
                    account.Company = strCompanyID;

                    account.UserID = strUserID;
                    account.UserName = strUserName;
                    account.Password = strPassword;

                    account.Save();
                    this.m_Server.AccountManager.Save();

                    //account.Role = strRole;
                    //account.Group = strGroup;
                    //account.Privilege = strPrivilege;

                    Send(newIq);
                }

            }