Chat Problems

Last post 01-07-2008, 8:46 AM by cutechat. 1 replies.
Sort Posts: Previous Next
  •  01-01-2008, 9:03 PM 36106

    Chat Problems

    Hello,
     
    We plan to use CuteChat4 in our website, the chat is working, I log on to Chat and everything goes fine, but when i open a new Internet explorer window and I log on with another user and I click the messenger link, the chat thinks that I'm the same user, and the don't create a new messenger, just show the user that is online, I don't know what is the problem, I follow careful the developer's guide.
     

    Thanks for any help.

    Regards, Marven.
     
    Global.asax.cs
     
        public class Global : System.Web.HttpApplication
        {
            protected void Application_Start(object sender, EventArgs e)
            {
                lock (typeof(CuteChat.ChatSystem))
                {
                    if (!CuteChat.ChatSystem.HasStarted)
                    {
                        CuteChat.ChatProvider.Instance = new Web_Messenger.Class.SampleProvider();
                        CuteChat.ChatSystem.Start(new CuteChat.AppSystem());
                    }
                }
            }

            protected void Application_End(object sender, EventArgs e)
            {

            }

            protected void Application_AuthenticateRequest(Object sender, EventArgs e)
            {
                //Fires upon attempting to authenticate the use
                if (this.Request.IsAuthenticated)
                {
                    FormsIdentity fi = (FormsIdentity)HttpContext.Current.User.Identity;
                    FormsAuthenticationTicket fat = fi.Ticket;

                    String[] astrRoles = fat.UserData.Split('|');
                    //HttpContext.Current.User = new GenericPrincipal(fi, astrRoles);
                    this.Context.User = new GenericPrincipal(this.User.Identity, astrRoles);
                }
            }
        }

    My Provider:
        public class SampleProvider: CuteChat.ChatProvider
        {
            #region Constantes
            const string _CONNECTION_STRING = "server=XPLEVEL6""XPLEVEL5;database=PHIENSA;uid=phiensa;pwd=phiensa";
            #endregion
            public override string GetConnectionString()
            {
                try
                {
                    return _CONNECTION_STRING;
                }
                catch (Exception Error)
                {
                    throw new Exception(Error.Message);
                }
            }
            public override CuteChat.AppChatIdentity GetLogonIdentity()
            {
                try
                {
                    HttpContext Context = HttpContext.Current;
                    if (Context != null)
                    {
                        if (Context.User.Identity.IsAuthenticated)
                        {
                            //MembershipUser User = Membership.GetUser();

                            string LoginName = Context.User.Identity.Name;
                            string UserId = ToUserId(LoginName);
                            string NickName = null;
                            bool Valid = GetUserInfo(LoginName, ref NickName);
                            if (Valid)
                                return new CuteChat.AppChatIdentity(NickName, false, UserId, Context.Request.UserHostAddress);
                            else
                                return null;

                        }
                    }
                    return null;
                }
                catch (Exception Error)
                {
                    throw new Exception(Error.Message);
                }
            }
            public override string FindUserLoginName(string nickName)
            {
                try
                {
                    BusinessGeneral BusinessPartner = new BusinessGeneral();
                    string Alias = BusinessPartner.ForceToGetAlias(nickName);
                    if (Alias != null)
                        return nickName;
                    return null;
                }
                catch (Exception Error)
                {
                    throw new Exception(Error.Message);
                }
            }
            public override bool GetUserInfo(string loginName, ref string nickName)
            {
                try
                {
                    BusinessGeneral BusinessPartner = new BusinessGeneral();
                    string Id = BusinessPartner.ForceToGetId(loginName);
                    if (Id != null)
                    {
                        nickName = loginName;
                        return true;
                    }
                    return false;
                }
                catch (Exception Error)
                {
                    throw new Exception(Error.Message);
                }
            }
            public override bool GetUserInfo(string loginName, ref string nickName, ref bool isAdmin)
            {
                try
                {
                    BusinessGeneral BusinessPartner = new BusinessGeneral();
                    string Id = BusinessPartner.ForceToGetId(loginName);
                    if (Id != null)
                    {
                        nickName = loginName;
                        isAdmin = (nickName == "Admin");
                        return true;
                    }
                    return false;
                }
                catch (Exception Error)
                {
                    throw new Exception(Error.Message);
                }
            }
            public override bool ValidateUser(string loginName, string password)
            {
                try
                {
                    BusinessGeneral BusinessPartner = new BusinessGeneral();
                    string Id = BusinessPartner.ForceToGetId(loginName);
                    return (Id != null);
                }
                catch (Exception Error)
                {
                    throw new Exception(Error.Message);
                }
            }
            public override bool IsAdministrator(string id)
            {
                MembershipUser User = Membership.GetUser();
                return (User.UserName == "Admin");
            }
        }
     

  •  01-07-2008, 8:46 AM 36182 in reply to 36106

    Re: Chat Problems

    Hi,
     
     
    The messenger do not allow multi-instance of same PC .
     
    So please use FireFox to test another messenger . or use another PC.
     
    ---
     
    by the way , the
            public override bool IsAdministrator(string id)
            {
                MembershipUser User = Membership.GetUser();
                return (User.UserName == "Admin");
            }
    is wrong.
     
    the id shoud be "User:loginname" , so please do not use Membership.GetUser() to get the current user.
    use the argument id to find the user , and then return true if the id is admin.
     
    Regards , Terry .
View as RSS news feed in XML