Establishing User Relationships on the fly

Last post 02-15-2009, 8:29 AM by lovelydoo. 10 replies.
Sort Posts: Previous Next
  •  11-24-2007, 3:57 PM 35350

    Establishing User Relationships on the fly

    Hello All,
     
    My client requested that the online users for our project autmatically get added to the buddy list as you launch the IM.
     
    I had it working with the previous version.  However, I cannot get a sence for how the new one adds users to the buddy list.
     
    Since users are already logged into the web site and have the same usernames for the IM and Chat, I simply add their DisplayName and UserId to the CuteChat4_User table. This allows me to manually add the users available in this table.  yet, no changes are made to the BuildinContacts field.
     
    Can someone tell me either instructions for my set up or point me in the right direction?
     
    Thanks
     
    Jack
  •  11-25-2007, 11:13 AM 35352 in reply to 35350

    Re: Establishing User Relationships on the fly

    Hi.
     
    You need to override the method for your custom chat provider :
     
     
    public class MyCustomProvider : ChatProvider
    {
    public override AppDataManager CreateDataManagerInstance(AppPortal portal)
    {
     return new MyDataManager(portal);
    }
    }
     
    And then , you can override the code , and return your contact list .

    public class MyDataManager : AppDataManager
    {
     public override void AddContact(ChatIdentity identity, string userid)
     {
      string myname=ChatProvider.Instance.FromUserId(identity.UniqueId);
      string friendname=ChatProvider.Instance.FromUserId(userid);
      MyCommunityDatabase.AddFriend(myname);
      this.OnContactAdded(identity,userid,friendname);
     }
     public override void RemoveContact(ChatIdentity identity, string userid)
     {
      //get the username from cutechat's userid
      string myname=ChatProvider.Instance.FromUserId(identity.UniqueId);
      string friendname=ChatProvider.Instance.FromUserId(userid);

      //my custom implementation
      MyCommunityDatabase.RemoveFriend(myname,friendname);

      //tell cutechat that the relative have been removed.
      this.OnContactRemoved(identity,userid);
     }
     public override IChatUserInfo[] GetContacts(ChatIdentity identity)
     {
      string myname=ChatProvider.Instance.FromUserId(identity.UniqueId);
      string[] friends=MyCommunityDatabase.GetFriends(myname);
      IChatUserInfo[] arr=new IChatUserInfo[friends.Length];
      for(int i=0;i<friends.Length;i++)
      {
       string friendid=ChatProvider.Instance.ToUserId(friends[ i ]);
       arr[ i ]=base.GetUserInfo(friendid);
      }
      return arr;
     }

     public override void AddIgnore(ChatIdentity identity, string userid)
     {
      base.AddIgnore (identity, userid);
     }
     public override void RemoveIgnore(ChatIdentity identity, string userid)
     {
      base.RemoveIgnore (identity, userid);
     }
     public override IChatUserInfo[] GetIgnores(ChatIdentity identity)
     {
      return base.GetIgnores (identity);
     }


     public MyDataManager(AppPortal portal):base(portal)
     {
     }
    }
     
     
    Hope this helps.
     
    Regards , Terry .
     
  •  11-26-2007, 6:16 PM 35398 in reply to 35352

    Re: Establishing User Relationships on the fly

    Terry,
    thanks a lot for your reply.
     
    I am still having problems due to the fact that I the changes are not reflected in the database. 
     
    As I understand this, correct me if I'm wrong, the users get added to CuteChat4_User table if they haven't been added yet. When friends list is populated, the chages go into the Buildincontacts field of the same table.  I get a test user appear as a friend in the IM contacts in Offline section. When I delete both users from the CuteChat4_user table, the friend still appears in offline after a recompile as if the data is stored in a completely different place.
     
    If possible, could you please explain the algorithm of what happens when CuteChat is first initialized with an identity. Does it get stored in the database at that point?
     
    When a list of friends is added, where are the nicknames picked from. 
     
    What I'm trying to achieve is pretty simple (since I come in with an authenticated user and need to display other users (logged in within last 30 minutes) in the friend list.
     
    I was able to do this in the previous version by adding or modifying records directly in the CuteChat tables.
     
    Thanks for your help.
     
    Jack
  •  11-27-2007, 9:02 AM 35416 in reply to 35398

    Re: Establishing User Relationships on the fly

    Jack:

    The first point is , do not modify the database directly. So please change the data of table CuteChat4_User.

    CuteChat would not know you have modify it and would not load the changes.

    When you want to do the integration , You can do using two way :

    1. by implementing the ChatProvider , override some virtual method and return your data.

    2. by calling the CuteChat API , like CuteChat.ChatApi.Xxx , CuteChat.ChatSystem.Instance.GetCurrentPortal().DataManager.AddContact(..)
     
    The Identity is initialized at the ChatProvider.GetLogonIdentity() , and other place when the user is anonymous.
     
    I am not so clear what you want to do exactly .
    Can you explain it clearly ?
     
    Thanks.

    Regards , Terry .

     

  •  12-04-2007, 3:10 PM 35644 in reply to 35416

    Re: Establishing User Relationships on the fly

    Hi
     
    I am trying to use the method AppDataManagerInstance.OnContactAdded(identity,userid,friendname); that you mentioned in your post.
     
    First, my version only takes 2 param: identity and userid. Is identity the identity of the user being added?
     
    Second, do you have an example of using an AppDataManager object by itself? How does it the DB to connect? ...
     
    Do you have an API doc for the CuteChat app? how about code examples? I don't useany framework such as DotNet Nuke ...
     
    thank you
  •  12-06-2007, 2:55 PM 35717 in reply to 35644

    Re: Establishing User Relationships on the fly

    Hi :
     
    Because not many developer use the kernal API ,so we haven't prepair the API documents yet.
     
    For the OnContactAdded method , the first argument mean the current user.
     
    You can use new AppChatIdentity(...) like the ChatProvider integration code does.
     
    the userid mean the target contact user being added.
     
    But I am not sure the OnContactAdded would resolve your request.
     
    --
    the AppDataManager just provide some API to read/write data to database .
    We will provide more documents on it .
     
    If you have more question on the class , please post it to the forum.
     
     
    Regards , Terry .
  •  05-09-2008, 8:43 AM 40246 in reply to 35352

    Re: Establishing User Relationships on the fly

    Does anyone have this code in VB?  Actually, very specifically I'm interested in the

    GetContacts

    function.  I converted the rest with no problems, but I'm having a hard time initializing the arr() in VB.Net to Ichatuserinfo (because it's an interface).  Any ideas?
  •  05-15-2008, 1:43 PM 40426 in reply to 40246

    Re: Establishing User Relationships on the fly

    Is anyone still using this forum?  Anyone from CuteSoft?
  •  05-28-2008, 6:57 AM 40837 in reply to 40426

    Re: Establishing User Relationships on the fly

    create your own "GetUserInfo" method - i called mine "GetUserInfo2"

    For i As Integer = 0 To friends.Length - 1

    Debug.WriteLine("this is the friend value being passed in " & friends(i))

    Dim friendid As Integer = qChat.ToUserId(friends(i))

    arr(i) = qChat.GetUserInfo2(friendid)

    Debug.WriteLine("adding to array..")

    Next

    Debug.WriteLine("ended loop")

    Return arr
     
     
    --------  the method
     
     

    Public Shared Function GetUserInfo2(ByVal friendid As Integer) As IChatUserInfo

    Debug.WriteLine("about to create appUserINfo with this friend id " & friendid)

    Dim userInfo As IChatUserInfo = New AppUserInfo(friendid.ToString())

    Debug.WriteLine("app user info created")

    Debug.WriteLine("this is the friend id now " & friendid)

    userInfo.DisplayName = qFun.getUserNameFromID(friendid)

    Debug.WriteLine("display name for info " & userInfo.DisplayName)

    Return userInfo

    End Function

     
     
  •  01-03-2009, 11:46 AM 47378 in reply to 35352

    Re: Establishing User Relationships on the fly

    Hello,
     
    I'm using the trial version of webmessenger 4.0 that I'm trying to integrate into my website.
    The users have the possibility to create their contacts in the website and I would like their contacts to be automatically displayed in Web Messenger.
    I've done what you advise below, and I use it like that :

    CuteChat.ChatPortal portal = CuteChat.ChatSystem.Instance.GetCurrentPortal();
    lock (portal)
    {
    CuteChat.
    ChatIdentity identity = ChatWebUtility.GetLogonIdentity();
    portal.DataManager.AddContact(identity,
    "User:"+conv.toString(dr["login"]));
    }


    I don't have any error but I don't see the new contact in the web messenger nor in the database.
    Have I missed something ? Is there anything more I should do after that ?

    Thank you for your help.

    Karine
     
     
     
  •  02-15-2009, 8:29 AM 48806 in reply to 47378

    Re: Establishing User Relationships on the fly

    grazie
     
    funziona perfettamente ..
     

    Protected Sub LinkButton5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton5.Click

    Dim portal As CuteChat.ChatPortal = CuteChat.ChatSystem.Instance.GetCurrentPortal()

    SyncLock portal

    Dim identity As CuteChat.ChatIdentity = CuteChat.ChatWebUtility.GetLogonIdentity()

    portal.DataManager.AddContact(identity, "User:" & "bobby")

    form ignore 1° add user 2° ignore

    portal.DataManager.AddIgnore(identity, "User:" & "bobby")

    End SyncLock

    End Sub

View as RSS news feed in XML