亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

UCMA設置lync在線狀態

標簽:
SQL Server

摘要

UCMA全称Microsoft Unified Communications Managed API,主要用来构建工作在Microsoft Lync Server上的中间层应用程序。开发人员可以使用该平台构建应用程序,以提供对 Microsoft Lync Server增强状态信息、即时消息、电话、视频呼叫和音频/视频会议的访问和控制能力。

在线状态

通过UCMA方式,设置lync客户端的在线状态。设置在线状态为 UCMA Online的SDK方法如下:

复制代码

  private static AutoResetEvent _PresencePublishComplete = new AutoResetEvent(false);        private static String _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 void SetLyncOnline(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 is also possible to create a category                // in other, more simple ways, shown below.                CustomPresenceCategory _note = new CustomPresenceCategory("note", String.Format(_noteXml, _noteValue));                // The PresenceState class has several static properties                // and methods which will 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" will                // be shown in Microsoft Lync.                LocalizedString localizedCallString = new LocalizedString(                    "UCMA Online" /* The string to be displayed. */);                // Create a PresenceActivity indicating the                // "In a call" state.                PresenceActivity inACall = new PresenceActivity(                    localizedCallString);                // Set the Availability of the "In a call" state to Busy.                inACall.SetAvailabilityRange((int)PresenceAvailability.Online,                    (int)PresenceAvailability.IdleOnline);                // Microsoft Lync will also show the Busy presence icon.                PresenceState _phoneState = new PresenceState(                        (int)PresenceAvailability.Online,                        inACall,                        PhoneCallType.Voip,                        "phone uri");                // Machine or Endpoint states must always be published to                // indicate the endpoint is actually online, otherwise it is                // assumed the endpoint is offline, and no presence                // published from that endpoint will 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 = new ContactCard(3);                LocalizedString localizedTitleString = new LocalizedString(                    "" /* The title string to be displayed. */);                _contactCard.JobTitle = localizedTitleString.Value;                // Publish a photo                // If the supplied value for photo is 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(                        new PresenceCategory[]                        {                            _userState,                            _phoneState,                            _machineState,                            _note,                            _contactCard                        },                        PublishPresenceCompleted, /* async callback when publishing operation completes. */                        true /* value TRUE indicates that presence to be 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 void PublishPresenceCompleted(IAsyncResult result)        {            try            {                // Since the same call back function is used to publish                // presence categories and to delete presence categories,                // retrieve the flag indicating which operation is desired.                bool isPublishOperation;                if (result.AsyncState == null)                {                    isPublishOperation = false;                }                else                {                    bool.TryParse(result.AsyncState.ToString(), out isPublishOperation);                }                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                // 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());            }        }

复制代码

點擊查看更多內容
TA 點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學習,寫下你的評論
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消