Re: Users are not appearing online in Cute WebMessanger

  •  08-28-2009, 12:28 AM

    Re: Users are not appearing online in Cute WebMessanger

    Ok Terry, Can you check my chat provider and let me know where am i getting wrong.
     

      public override void Init()
            {
                base.Init();

                lock (typeof(CuteChat.ChatSystem))
                {
                    if (!CuteChat.ChatSystem.HasStarted)
                    {
                        CuteChat.ChatProvider.Instance = new MyChatProvider();
                        CuteChat.ChatSystem.Start(new CuteChat.AppSystem());
                     
                    }
                }
            }


     public class MyChatProvider : CuteChat.ChatProvider
            {
                /// <summary>
                /// Get connection string for Cute Chat
                /// </summary>
                /// <returns></returns>
                public override string GetConnectionString()
                {
                    return ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
                }

                /// <summary>
                /// Find a user and return its loign name from the display name or null if
                /// the user is not found
                /// </summary>
                /// <param name="nickName"></param>
                /// <returns></returns>
                public override string FindUserLoginName(string nickName)
                {
                    BL.Users.User user = Utilities.FindUser(nickName);  //nickName should be email here

                    if (user.UserID <= 0)
                        return null;
                    else
                        return user.Email;
                }

                /// <summary>
                /// Get the LogonIdentity for the current user
                /// to be used in Cute Chat
                /// </summary>
                /// <returns></returns>
                public override AppChatIdentity GetLogonIdentity()
                {
                  //need to find the information of current user. Return null if user is anonymous.
                  //string loginname=...
                  //string nickname=...
                  //return new AppChatIdentity(nickname, false, ToUserId(loginname), HttpContext.Current.Request.UserHostAddress);

                    UserContext userContext = UserContext.Get(HttpContext.Current.Session);
                    if (userContext.UserID <= 0)
                        return null;
                    return new AppChatIdentity(userContext.UserName, false, ToUserId(Utilities.GetUserEmail()),                                  HttpContext.Current.Request.UserHostAddress);
                }

                /// <summary>
                /// returns false if the loginName is invalid
                /// else set the nickName and isAdmin, and return true
                /// </summary>
                /// <param name="loginName"></param>
                /// <param name="nickName"></param>
                /// <param name="isAdmin"></param>
                /// <returns></returns>
                public override bool GetUserInfo(string loginName, ref string nickName, ref bool isAdmin)
                {
                    BL.Users.User user = Utilities.FindUser(loginName);
                    if (user.UserID <= 0)
                        return false;
                    nickName = user.UserName;
                    isAdmin = false;
                    return true;
                }

                /// <summary>
                /// Validate a chat user
                /// </summary>
                /// <param name="loginName"></param>
                /// <param name="password"></param>
                /// <returns></returns>
                public override bool ValidateUser(string loginName, string password)
                {
                    bool isLogin = false;
                    BL.Users.User user = new Axero.Dyve.BL.Users.User();
                    user.Email = loginName;
                    user.Password = password;
                    isLogin = user.Login();
                    return isLogin;
                }
            }

     
    Well i'm trying to add contacts by email of users. Can you please check the above Chat provider and please let me know what to add insiickname and in loginname in GetLogonIdentity() mehtod.
     
    At present im passing  
    //need to find the information of current user. Return null if user is anonymous.
                  //string loginname=...
                  //string nickname=...
                  //return new AppChatIdentity(nickname, false, ToUserId(loginname), HttpContext.Current.Request.UserHostAddress);         
     return new AppChatIdentity(userContext.UserName, false, ToUserId(Utilities.GetUserEmail()),                                  HttpContext.Current.Request.UserHostAddress);
     
     
    In Our messenger we are adding users by the EmailID
     
    Please check the code .
    Thanks.

     
View Complete Thread