I'm writing a UCMA 2.0 application which connects with a 'UserEndpoint' to OCS. I want to be able to set a custom presence message along with my availability!
I've run into some issues along the way and spent a lot of time Googling and tried out a few articles, the majority seem to be saying the same thing (including MS themselves):
Use XML to set the 'userState' activity to be custom and contain a message, then publish that in a custom category via the endpoint's 'LocalOwnerPresence.BeginPublishPresence' method.
I don't get any errors back from OCS when I do this (see the XML example below), but looking at the presence in Office Communicator (MOC) the user in question continues to appear offline. I have found that also publishing the 'machineState' means that we see some presence icon in MOC, but alas, I can't get the custom activity message working.
More reading sent me on wild goose chases, such as stored procs in the OCS DB that need to be run to allow this (sounded more like for adding brand new presence categories rather than just a custom message to an existing state). I'm kind of at the end of my tether after a day 'online'.
Any help or pointing out any gotchas would be appreciated! I've included a few of the sites I used when reading up on this:
Presence Intro: http://msdn.microsoft.com/en-us/library/dd253506(v=office.13).aspx
Publishing Presence: http://msdn.microsoft.com/en-us/library/dd253494(v=office.13).aspx
Presence + Custom messages: http://blogs.claritycon.com/blog/2009/03/04/how-to-publish-presence-using-ucma-v2-0-and-have-a-clever-communicator-status/
Machine state ideas: http://social.msdn.microsoft.com/Forums/en-US/ucmanagedsdk/thread/d3bd3569-66c0-4b52-86f0-900d2fb6d22e/
Presence Schema doc: http://msdn.microsoft.com/en-us/library/dd941536(v=office.13).aspx
Here's the XML (string) that I'm using in my code, on the fly I string.Format the placeholders with a custom message and an availability integer value ("test message" and 3500 for the sake of argument).
string userStateXmlFormat = "<state xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" manual=\"true\" xsi:type=\"userState\">\n"
+ "<availability>{0}</availability>\n"
+ "<activity>\n"
+ "<custom xmlns=\"http://schemas.microsoft.com/2006/09/sip/state\">{1}</custom>\n"
+ "</activity>\n"
+ "</state>";
Here's the C# that does the formatting, and attempting to publish the presence:
var machineStateXml = string.Format(machineStateXmlFormat, 3500);
var userStateXml = string.Format(userStateXmlFormat, 3500, "Test Message");
var machineState = new CustomPresenceCategory("state", machineStateXml);
var userState = new CustomPresenceCategory("state", userStateXml);
PresenceCategory[] categoriesToPublish = new PresenceCategory[] { machineState, userState };
this.Endpoint.LocalOwnerPresence.BeginPublishPresence(categoriesToPublish, this.PublishPresenceCompleted, null);
Hopefully I haven't left anything out, please comment if you think there's something missing!
Cheers Pete