public static void ProccessAuthSet(string username, string SID, int UserSessionIndex, IQ iq) { Auth auth = iq.Query as Auth; iq.SwitchDirection(); string cuser = auth.Username; string cpass = auth.Digest; if (!string.IsNullOrEmpty(cuser) && !string.IsNullOrEmpty(cpass)) { if (!ThreadTools.Users.Online[UserSessionIndex].Authenticated) { int UserIndex; if (!ThreadTools.Users.Online.IsAuthenticated(cuser, out UserIndex)) { BLL.Users api = new BLL.Users(); if (api.LoginMessenger(cuser, SID, cpass)) { iq.Type = IqType.result; ThreadTools.Users.Online[UserSessionIndex].Authenticated = true; ThreadTools.Users.Online[UserSessionIndex].Username = cuser; iq.Query = null; ThreadTools.Users.Online[UserSessionIndex].Send(iq); api.ChangeUserStatus(cuser, true); Presence p = Rosters.GetPresence(cuser); p.To = new agsXMPP.Jid(cuser + "@" + Config.AppSetting.domain); ThreadTools.Users.Online[UserSessionIndex].Send(p); Rosters.SendStatus(cuser); } else { iq.Type = IqType.error; iq.Query = null; iq.AddChild(new agsXMPP.protocol.client.Error(ErrorType.auth, ErrorCondition.NotAuthorized)); ThreadTools.Users.Online[UserSessionIndex].Send(iq); } } else { iq.Type = IqType.error; iq.Query = null; iq.AddChild(new agsXMPP.protocol.client.Error(ErrorType.auth, ErrorCondition.Conflict)); ThreadTools.Users.Online[UserSessionIndex].Send(iq); } } } else { iq.Type = IqType.error; iq.Query = null; iq.AddChild(new agsXMPP.protocol.client.Error(ErrorType.auth, ErrorCondition.NotAcceptable)); ThreadTools.Users.Online[UserSessionIndex].Send(iq); } }