Adding contacts and seeing messenger status programatically

Last post 08-01-2011, 12:44 PM by rgettel. 5 replies.
Sort Posts: Previous Next
  •  07-29-2011, 3:56 PM 69023

    Adding contacts and seeing messenger status programatically

    I'm working on a page where users can see lists of who is online and currently chatting and I am trying to create functionality to interact with the messenger and hitting a few road blocks.
     
    1) I have the code in place to add a contact using:
    ChatSystem.Instance.GetCurrentPortal().DataManager.AddContact(GetLoggedInUserIdentity(), userLoginID);
    where GetLoggedInUserIdenty returns the current user's AppChatIdentity and userLoginID is the user id of the person to add to the contact list.  This works but the added user's display name is always blank (profile picture shows up fine).  How do I get the suer added with their name displayed?  Adding a user through the messenger's add contact popup works correctly.
     
    2) My page displays all online users btu I would like to show which users are currently using their messenger and which are not.  In messenger this is denoted by either a green dot beside their name or a yellow clock face.  How can I make this determination programatically?
     
    3) I would like to be able to start a conversation with an online member straight from this page.  How can I open a conversation with the user from an external page?
  •  08-01-2011, 7:49 AM 69114 in reply to 69023

    Re: Adding contacts and seeing messenger status programatically

    Hi rgettel,
     
     
    1. I can not reproduce this problem. do you mean it shows a empty name in the contact list if the friend add by this code? Can you post some screenshots to show this issue?
     
    2.  You can get the user status by the code below
     
        CuteChat.ChatPortal portal = CuteChat.AppSystem.Instance.GetCurrentPortal();
                lock (portal)
                {
                    if (portal.IsMessengerStarted)
                    {
                        CuteChat.ChatPlaceUser user = portal.Messenger.FindUser("User:admin");

                        if (user != null)
                        {
                            // get the user status by user.OnlineStatus
                            label1.Text = user.OnlineStatus;
                        }
                    }
                }
     
     3.  Please try method Chat_OpenContact('userId'),like
     
    <a href="#" onclick="Chat_OpenContact('admin')"><img src="CuteSoft_Client/CuteChat/Images/avatar.gif">admin</a>
     
     
    Regards,
     
    ken
  •  08-01-2011, 9:28 AM 69122 in reply to 69114

    Re: Adding contacts and seeing messenger status programatically

    Above find a screen shot of issue one.  The top one is the user added programatically (server side C#) and the bottom is the user added through the add contact dialog (javascript).  Found that could still add the user via the dialog and that chat with him worked correctly.  Chat with the programmatically added version opens a conversation but doesn't interact with the user.  In the database the entry contains the following values pertaining to the two contacts : 11=kengelhardt;,16=User:kengelhardt;
    Thanks!
  •  08-01-2011, 10:43 AM 69127 in reply to 69122

    Re: Adding contacts and seeing messenger status programatically

    HI rgettel,
     
    Can you show me the whole code of your "Add Contact" method?
     
    Regards,
     
    ken
  •  08-01-2011, 12:03 PM 69131 in reply to 69127

    Re: Adding contacts and seeing messenger status programatically

    public AppChatIdentity GetLoggedInUserIdentity() //Gets CuteChat Identity of logged in user

    {

    var userManager =newUserManager();

    var userName = userManager.GetUserInfo(UserID).UserId;

    return new AppChatIdentity(userName,false,"User:"+ userName,HttpContext.Current.Request.UserHostAddress);

    } 

    public void AddUserToContactList(string userLogginID) //Add parameter user logged in user's contact list

    {

    ChatSystem.Instance.GetCurrentPortal().DataManager.AddContact(GetLoggedInUserIdentity(), userLogginID);

    }

  •  08-01-2011, 12:44 PM 69132 in reply to 69131

    Re: Adding contacts and seeing messenger status programatically

    Ahhh, think I figured it out, it should be:
     

    public voidAddUserToContactList(stringuserLogginID) //Add parameter user logged in user's contact list

    {

    ChatSystem.Instance.GetCurrentPortal().DataManager.AddContact(GetLoggedInUserIdentity(), "User:" + userLogginID);

    }
     
    This seems to add the user approprately.  Still integrating the other answers and they work great.  Thanks for your help!
View as RSS news feed in XML