UCMA setting up Lync Online Status

Source: Internet
Author: User
Tags call back

Summary

The UCMA full name is the Microsoft Unified Communications Managed API, which is used primarily to build middle-tier applications that work on Microsoft Lync Server. Developers can use the platform to build applications that provide access and control of Microsoft Lync Server enhanced presence information, instant messaging, telephony, video calls, and audio/video conferencing.

Online status

Set the online status of the Lync Client in UCMA mode. The SDK methods for setting the online status UCMA online are as follows:

  Private StaticAutoResetEvent _presencepublishcomplete =NewAutoResetEvent (false); Private StaticString _notexml ="<note xmlns=\ "http://schemas.microsoft.com/2006/09/sip/note\" >"+"<body type=\ "personal\" uri=\ "\" >{0}</body></note>"; Private Static string_notevalue ="Gone Fishing";  Public voidsetlynconline (Userendpoint uep) {Try{_localownerpresence=UEP.                Localownerpresence; //Tcoll.add (_localownerpresence.subscriberendpoint.ownerdisplayname,_localownerpresence); //The Custompresencecategory class enables creation of a//category using XML. This allows precise crafting of a//category, but it's also possible to create a category//in and more simple ways, shown below.Custompresencecategory _note =NewCustompresencecategory ("Note", String.Format (_notexml, _notevalue)); //The Presencestate class has several static properties//and methods which would provide standard states such as//online, busy, and On-the-phone, for example.Presencestate _userstate =presencestate.useravailable; //It is possible to create and publish state with a//custom availablity string, shown below. "In a call" would//Be shown in Microsoft Lync.LocalizedString localizedcallstring =NewLocalizedString ("UCMA Online" /*The string to is displayed.*/); //Create a presenceactivity indicating the//' in a call ' state.Presenceactivity Inacall =Newpresenceactivity (localizedcallstring); //Set The availability of the ' in a ' call ' state to Busy.Inacall.setavailabilityrange ((int) Presenceavailability.online, (int) presenceavailability.idleonline); //Microsoft Lync would also show the Busy presence icon.Presencestate _phonestate =NewPresencestate ((int) Presenceavailability.online, Inacall, Phonecalltype.voip, "phone URI"); //Machine or Endpoint states must all is published to//indicate the endpoint is actually online, otherwise it is//assumed the endpoint is offline, and no presence//Published from that endpoint'll be displayed.Presencestate _machinestate =Presencestate.endpointonline; //It is also possible to create presence categories such//As Contactcard, Note, Presencestate, and Services with//their constructors. //Here we create a contactcard and change the title.Contactcard _contactcard =NewContactcard (3); LocalizedString localizedtitlestring=NewLocalizedString ("" /*The title string to is displayed.*/); _contactcard.jobtitle=Localizedtitlestring.value; //Publish a photo//If the supplied value for photo was null or empty, then set value of Isallowedtoshowphoto to False_contactcard.isallowedtoshowphoto =false; _contactcard.photouri=NULL; //Publish All presence categories with new values._localownerpresence.beginpublishpresence (Newpresencecategory[] {_userstate, _phones                        Tate, _machinestate, _note, _contactcard }, Publishpresencecompleted,/*Async Callback when publishing operation completes.*/                        true /*value TRUE indicates this presence to is published with new values.*/); //_presencepublishcomplete.waitone ();            }            Catch(publishsubscribeexception PSE) {//Publishsubscribeexception is thrown when there were//exceptions during this presence operation such as badly//formed SIP request, duplicate publications in the same//request etc. //TODO (left to the reader): Include Exception handling Code//Here .Console.WriteLine (PSE.            ToString ()); }            Catch(Realtimeexception Rte) {//Realtimeexception is thrown when sip Transport, sip//authentication, and credential-related errors are//encountered. //TODO (left to the reader): Include Exception handling Code//Here .Console.WriteLine (Rte.            ToString ()); }        }
  Private voidpublishpresencecompleted (IAsyncResult result) {Try            {                //Since the same call back function was used to publish//presence categories and to delete presence categories,//retrieve the flag indicating which operation is desired.                BOOLispublishoperation; if(result.) AsyncState = =NULL) {ispublishoperation=false; }                Else                {                    BOOL. TryParse (result. Asyncstate.tostring (), outispublishoperation); }                if(ispublishoperation) {//Complete the publishing of presence categories._localownerpresence.endpublishpresence (Result); Console.WriteLine ("presence State has been published."); }                Else                {                    //Complete the deleting of presence categories._localownerpresence.enddeletepresence (Result); Console.WriteLine ("presence State has been deleted."); }            }            Catch(publishsubscribeexception PSE) {//Publishsubscribeexception is thrown when there were//exceptions during the publication of this category such as//badly formed SIP request, duplicate publications in the same//Request etc//TODO (left to the reader): Include Exception handling Code// HereConsole.WriteLine (PSE.            ToString ()); }            Catch(Realtimeexception Rte) {//Realtimeexception is thrown when sip Transport, sip//authentication, and credential-related errors are//encountered. //TODO (left to the reader): Include Exception handling Code//Here .Console.WriteLine (Rte.            ToString ()); }        }

UCMA setting up Lync Online Status

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.