UCMA设置lync在线状态
摘要
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();
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());
}
}
UCMA设置lync在线状态的更多相关文章
- 用smack+openfire做即时通讯
首发:个人博客 必须说明:smack最新的4.1.1,相对之前版本变化很大,而且资料缺乏,官方文档也不好,所以还是用老版本3.2.2吧.这篇博文中的代码是4.1.1版的,但不推荐用它.用openfir ...
- 【Android进阶】为什么要创建Activity基类以及Activity基类中一般有哪些方法
现在也算是刚刚基本完成了自己的第一个商业项目,在开发的过程中,参考了不少人的代码风格,然而随着工作经验的积累,终于开始慢慢的了解到抽象思想在面向对象编程中的重要性,这一篇简单的介绍一下我的一点收获. ...
- 【Android先进】我们为什么要创建Activity基类Activity什么是一般的基类方法
今天,它可以被视为只是基本完成了其首个商业项目,在发展过程中,风格,然而随着工作经验的积累.最终開始慢慢的了解到抽象思想在面向对象编程中的重要性,这一篇简单的介绍一下我的一点收获. 首先,在如今的项目 ...
- iOS - XMPP 的使用
1.XMPP XMPP 是一个基于 Socket 通信的即时通讯的协议,它规范了即时通信在网络上数据的传输格式,比如登录,获取好友列表等等的格式.XMPP 在网络传输的数据是 XML 格式. 开发架构 ...
- QQ如何开通在线客服
一. 注册一个网站专用QQ. 二. 到QQ商家设置QQ在线状态:http://wp.qq.com/set.html 1.免费开通 2.根据你的需求设置 3,复制代码放置在html页面上即可,效果如下图
- MGR实现分析 - 成员管理与故障恢复实现
MySQL Group Replication(MGR)框架让MySQL具备了自动主从切换和故障恢复能力,举single primary(单主)模式为例,primary作为主节点对外提供读写服务,是唯 ...
- MySQL MGR实现分析 - 成员管理与故障恢复实现
此文已由作者温正湖授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. MySQL Group Replication(MGR)框架让MySQL具备了自动主从切换和故障恢复能力,举 ...
- MySQL MGR源码分析2 - 从start group_replication看MGR代码框架
此文已由作者温正湖授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 上一篇我们从方案层面讲解了MGR的成员管理和故障恢复.本篇从源码层面捋一捋,通过本篇介绍,除了能够了解如何将 ...
- Oracle 11g 学习3——表空间操作
一.表空间概述 表空间是Oracle中最大的逻辑存储结构,与操作系统中的数据文件相相应: 基本表空间:一般指用户使用的永久性表空间,用于存储用户的永久性数据 暂时表空间: 主要用于存 ...
随机推荐
- 转发:IT行业中的甲方乙方关系
原文:http://byteh.blog.51cto.com/141786/1004046/ 混IT,必须理解“甲方乙方” By 韩宇斌 2012-09-23 9月初,修改了QQ签名,把“甲方乙方”放 ...
- 65.Android 三大图片缓存原理、特性对比 (转)
这是 Trinea 在 MDCC 上分享的内容(略微改动),也是源码解析第一期发布时介绍的源码解析后续会慢慢做的事. 从总体设计和原理上对几个图片缓存进行对比,没用到他们的朋友也可以了解他们在某些特性 ...
- ubuntu16.04+cuda7.5
0 安装了ubuntu16.04 GT980的显卡,安装了nvidia340的驱动 1 下载cuda7.5的.run文件 2 进入tty1,service stop lightdm 3 sudo sh ...
- NOIP2013
DAY1 转圈游戏 列出式子(x+km)%n,快速幂. // codevs3285 #include<algorithm> #include<iostream> #includ ...
- hdu 4324 拓扑排序
题意:给出一堆人的喜爱关系,判断有没有三角恋-_-|| 其实就是判断是否存在三条边的环. 一开始我是这么想的: 先拓扑排序,如果没有环那就直接No 如果有环?挑出环里的任意一个点(拓扑排序结束后不在拓 ...
- php面向对象中static静态属性和静态方法的调用
这篇文章主要介绍了php面向对象中static静态属性和静态方法的调用,实例分析了static静态属性和静态方法的原理与调用技巧,需要的朋友可以参考下 本文实例讲述了php中static静态属性和静态 ...
- SPOJ GSS2 Can you answer these queries II
Time Limit: 1000MS Memory Limit: 1572864KB 64bit IO Format: %lld & %llu Description Being a ...
- 数据结构算法C语言实现(四)---2.3循环链表与双向链表
一.简述 [工作中...]
- vi命令大全
参考 http://www.cnblogs.com/88999660/articles/1581524.html 最近要用到linux和shell脚本,所以多学习下,反正没什么坏处 在linux里面, ...
- springMVC 基于注解的controller
概述 继 Spring 2.0 对 Spring MVC 进行重大升级后,Spring 2.5 又为 Spring MVC 引入了注解驱动功能.现在你无须让 Controller 继承任何接口,无需在 ...