none
presence unknown in office communicator sdk

    Question

  • Hi,

    I created a sample application using Microsoft office communicator sdk. Everthing is fine.
    But i need to get the presence status to get the status of the contact , irrespective of whether the person is in the contact-list of the communicator client or not.

    I  have checked a lot of things but in vain.
    The problem is that i'm getting the presence status as unknown during sometimes.
    I don't know actually how to resolve this.

    Is there anyway to get rid of this.
    Any help in this regard will be really appreciated.

    Thanks in advance,
    Janani
    Tuesday, August 04, 2009 6:52 AM

All replies

  • Hi,

    Can you tell how you are getting the presence status of the contact?

    We are using the "messenger_OnIMWindowContactAdded" event,  in which the Contact presence property shows up properly.

    -Monty
    Aditi Technologies, Bangalore
    India
    Tuesday, August 04, 2009 7:10 AM
  • Hi,

    Sincere thanks for ur reply first.

    I'm using the following snippet to get the presence status of the contact.

    contact = communicator.GetContact(sipUri, communicator.MyServiceId) as IMessengerContact;
    participant = contact.FriendlyName;
    status = contact.Status.ToString();

    May I know please you are also using the office communicator sdk, i mean the office communicator automation API or some other one.

    Also  may I also know please are you adding the contact to the contact list to get the presence status ?

    One thing i wish to add here is......
    I want to get the status of the contact before the conversation starts up......
    The main objective here is to start the coversation only when the person is available..........


    Regards,
    Janani.
    Tuesday, August 04, 2009 9:26 AM
  • Hi,

    You are absolutely right with your description of behaviour you have given in the start of the thread. When the contact we want to subscribe presence to is not in the contact list, we get Presence unknown. If the contact is in the presence list then we get the correct presence status.

    We are using the communicator api. 

    As per your requirement you just need to check if the other contact is available before sending the message. 
    If you have noticed that when you want to search for a contact (in the communicator) as soon as you have entered the full username example : abc@def.com we get the presence of the user. Hence even before adding the contact it should be possible to get the presence of the user.

    Will look into this and let you know.

    -Monty
    Aditi Technologies, Bangalore
    India
    Tuesday, August 04, 2009 5:29 PM
  • Hi,

    I think i got it firstly use IMessengerContactAdvanced instead of IMessengerContact.
    Next see the property contact.PresenceProperty. I think this will answer your question.

    -Monty
    Aditi Technologies, Bangalore
    India
    Tuesday, August 04, 2009 5:46 PM
  • Hi,

    Thanks again........
    What you have understood is exactly right.....!!
    I want to know the status of the contact(irrespective of whether the contact is in the list or not in the list) and if available, i want to send some message.
    But it works fine previously with no problems initially..........(Don't know the reason)

    In the meanwhile , it got struck up like it will get the status as presence unknown even when the contact is available. That's the problem actually is......
    We can also keep noticed sometimes when we started typing the full name of the contact in the communicator, it got changed from unknown to their respective status.......I don know whether my application is fetching the status before the server response from OCS returns.........

    Then i came to know in the microsoft website......
    for the IMessengerContact, the status will initially retrieve as unknown which is provided in the remarks columns...........

    Anyway i ll try with IMessengerContactAdvanced and let u know..........!

    Regards,
    Janani

     

    Wednesday, August 05, 2009 9:54 AM
  • hi,

    i have tried with IMessengerContactAdvanced too........but in vain...........
    Any other way please....................??????????????

    I'm really getting mad in searching of this..........

    OR can u please share some code on how you are accomplishing this.......?
    Monday, August 10, 2009 1:10 PM
  • Hi Monty,

    Please tell me what you are using to get the updated accurate presence status for non-contacts.

    That issue is not yet resolved for me.......I've tried more ways but everything in vain.

    I have tried contact.status - it is showing presence_unknown.

    Then I tried contact.Presencepropeties too.........it is showing the status correctly.......to some extent...i.e.it is also showing presence_unknown for sometimes.

    But the thing it is caching the status of non-contacts somewhere it seems.....

    So when i fetch the status repeatedly, it is not showing the current presence status........only the previous status....

    Then I came to the conclusion that it is caching it somewhere else.

    So, is there anyway to clear the cache of the Microsoft Office communicator 2005.

    I found no methods available for this in the API reference.

    Or else is there some other way available to get the accurate status for non-contacts...........?

    Please help me out to get rid of this.

    Thanks in advance,

    Janani.

     

     

    Tuesday, August 18, 2009 9:52 AM
  • Hi,

    I have used the following lines of code..

    IMessengerContactAdvanced contact = messenger.GetContact("XYZ@Domain.com", messenger.MyServiceId) as IMessengerContactAdvanced;
    object presenceProp = contact.PresenceProperties;

    XYZ@Domain.com is not in the contact list and in the PresenceProperties which is an array, we get the following...

    array[1] contains an integer number which is the presence number.


    Use fields defined in the PRESENCE_PROPERTY enumeration type as the index of the returned property array to retrieve individual elements of the property array. When reading presence property values, a null value is returned as an element of the resultant array if the corresponding presence property value is not set.

    When the contact object is the user of the application, the application can set this property to publish the following presence status:

    • Availability: Set one of the following presence properties:
      • Set the PRESENCE_PROP_MSTATE property to empty or MISTATUS_UNKNOWN.
      • Set the PRESENCE_PROP_AVAILABILITY property to one of these values.
        Available

        3000

        Busy

        6000

        Do Not Disturb

        9000

        Be Right Back

        12000

        Away

        15000

        Appear Offline

        18000

    • System-defined activity: Set the PRESENCE_PROP_MSTATE to one of the following values:
      • MISTATUS_DO_NOT_DISTURB
      • MISTATUS_ONLINE
      • MISTATUS_BUSY
      • MISTATUS_BE_RIGHT_BACK
      • MISTATUS_AWAY
    • Presence status: Set one of the following:
      • Set the PRESENCE_PROP_MSTATE to MISTATUS_UNKNOWN.
      • Set the PRESENCE_PROP_AVAILABILITY to zero if PRESENCE_PROP_MSTATE is not set.

     

     

    Please refer the links below:

    http://msdn.microsoft.com/en-us/library/bb758741.aspx

    http://msdn.microsoft.com/en-us/library/bb787249.aspx

     

     

    I suggest you should use the PresenceProperty array[1] field which is an integer value get the number and then based on the numbers defined above, get the presence state of the user.

     

     

    Also we are using Office communicator 2007 r2. I really dont think it makes a difference. It works perfectly fine in our set up and we are able to get the presence of any user.

     

    -Monty

    Aditi Technologies, Bangalore

    India

     

    Wednesday, August 19, 2009 4:16 AM
  • Hi,
    Thanks again.........

    Yes...I have used the same thing which you have shown above..........
    Below is my code..........

    contact = communicator.GetContact(XYZ@Domain.com , communicator.MyServiceId)as IMessengerContactAdvanced;

     if (int.Parse(((object[])contact.PresenceProperties)[1].ToString()) == 3000)
    status =
    "MISTATUS_ONLINE"; 
    else if (int.Parse(((object[])contact.PresenceProperties)[1].ToString()) == 4500)
    status =
    "MISTATUS_IDLE"; 
    else if (int.Parse(((object[])contact.PresenceProperties)[1].ToString()) == 6000)
    status =
    "MISTATUS_BUSY"; 
    else if (int.Parse(((object[])contact.PresenceProperties)[1].ToString()) == 9000)
    status =
    "MISTATUS_DO_NOT_DISTURB"; 
    else if (int.Parse(((object[])contact.PresenceProperties)[1].ToString()) == 12000)
    status =
    "MISTATUS_BE_RIGHT_BACK"; 
    else if (int.Parse(((object[])contact.PresenceProperties)[1].ToString()) == 15000)
    status =
    "MISTATUS_AWAY";
    else if (int.Parse(((object[])contact.PresenceProperties)[1].ToString()) == 18000)
    status =
    "MISTATUS_OFFLINE";
    else if (int.Parse(((object[])contact.PresenceProperties)[1].ToString()) == 0)
    status =
    "MISTATUS_UNKNOWN";

    In the above i'm getting the status correctly for the first time................
    But my scenario is like i have to ping them only when they are available.......So I'm using the GetContact method for the same sign in name(XYZ@domain.com) again and again.(i.e ) in a loop of ten members, i'll check for a specified time who are available again and again.

    But in the GetContact method in the office communicator API, I have found the following:
    If the IMessenger::GetContact method is invoked more than once using the same bstrSigninName input string, the same pointer is returned each time as long as ppMContact is not released or otherwise destroyed. 


    The reference link is:
    http://msdn.microsoft.com/en-us/library/bb758743.aspx

    So I tried like
    Marshal.ReleaseComObject(contact);

    But everything in vain...........................
    For example........
    For the first time for a contact, if I retrieved the status as "away".
    It is getting the status as away, even after the person came online.ie.I'm not getting the updated status.Only the previous pointer cached status or something else.
    I have scratched and explored the entire web.Nothing is available.
    So, is there anything available to clear the communicator cache.

    Or is there any method available to release the COM object.(ie.)the pointer to the pointer of the IDispatch interface
    Or what should I do to get rid of this.
    Please help me out..

    Regards,
    Janani.

    Wednesday, August 19, 2009 5:36 AM
  • If the contact that you are getting presence for is not on the users "permanent" contact list, that is it does not show up in the contact list in Office Communicator, then when you request the presence, OC will cache the returned value for 2 minutes.  If you call GetContact again in under 2 minutes, then OC will not query the server and will just hand you the cached value.

    This was implemented as a privacy measure to ensure that people could be notified (by the "foo has added you to his contact list" message) if someone was going to track their presence in real time.


    Oscar Newkerk Application Architect Unify Squared
    • Edited by Oscarn Wednesday, August 19, 2009 10:01 PM
    Wednesday, August 19, 2009 10:00 PM
  • hi,

    thanks for ur reply.......

    Is there anyway to obtain the accurate status of the sip(say: xyz@domain.com) without having them in the contact-list.................
    I tried everything but in vain..................

    Regards,
    Janani.
    Monday, August 24, 2009 12:49 PM
  • hi,

    Please help me out..........

    I came to know now only that my office communicator is blocking when i made some call to it through my methods.
    That's why i can't able to get the status properties i guess.

    How to relieve the OC from it and get the call results correctly.

    Please help me to get rid...............

    Thanks in advance,
    Janani.


    Tuesday, August 25, 2009 7:26 AM
  • Hi ,

    Please help me out how to relieve the office communicator from being blocked.
    For me, the problem which i have found out is,
    my communicator is blocking while i make a call to it through the automation API.

    When i'm accessing the communicator through my application, it is blocking where it behaving like the following:

    1. For those "recent contacts" which is not in the communicator list, it is showing presence_unknown
    2. For those contacts which is not in the communicator list, it is not updating the status......until it is relieved from my application.

    What's the remedy for this...? I guess now the presence_unknown problem is because of this behaviour.
    Please help me out.


    Thanks & Regards,
    Janani.

    Tuesday, August 25, 2009 11:24 AM
  • I was having this same problem.  I discovered that if the contact was not in my contact list, their status was not IMMEDIATELY available and therefore would return unknown.  So here's how I fixed it:

    1) Query for the user presence using IMessengerContactAdvanced , PresenceProperties

     

    2) If the contact returns unknown, use a sleep command 3 seconds (you may have to adjust)   system.threading.thread.sleep(3000)

    3) Then, have it try to query the status of the contact again.  I have found it then returns the correct status.

    Thursday, September 16, 2010 5:21 PM