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中最大的逻辑存储结构,与操作系统中的数据文件相相应: 基本表空间:一般指用户使用的永久性表空间,用于存储用户的永久性数据 暂时表空间: 主要用于存 ...
随机推荐
- bzoj4402: Claris的剑
首先,对于本质相同的构造,我们只计算字典序最小的序列 假设序列中最大的元素为top 我们很容易发现这样的序列一定是1,2,..,1,2,3,2,3,...,2,3,4,3,4.........,top ...
- python3下的paramiko 安装
环境为centos6.7 python3为源码编译安装的,系统自带的python2 可以直接使用paramiko模块,但是在py3的环境下加载出错,所有需要安装新的paramiko 模块: 上了par ...
- OPENGGL深度测试
深度测试是为了解决那些在绘图过程中本应该被隐藏的面结果却出现了,例如: 绘图代码中先绘制了一个一个近处的立方体,后绘制了一个远处的立方体,结果在绘制过程中,远处的立方体总是在近处的立方体后绘制,所以在 ...
- Leetcode 313. super ugly number
Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all ...
- 【BZOJ-3033】太鼓达人 欧拉图 + 暴搜
3033: 太鼓达人 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 204 Solved: 154[Submit][Status][Discuss] ...
- 【BZOJ-1369】Gem 树形DP
1369: [Baltic2003]Gem Time Limit: 2 Sec Memory Limit: 64 MBSubmit: 282 Solved: 180[Submit][Status] ...
- C#中的斜变性和逆变性的详解
1,问题 大家可以看到定义泛型类型的可以看到out和in这两个关键字,那么具体代表什么意思呢? 2,文字解释 C# 4.0通过两个关键字:out和in来分别支持以协变和逆变的方式使用泛型. 如果某个返 ...
- Jenkins实现测试环境到生产环境一键部署(Windows)
前言: 因为dotnet在发布站点后,然后再上传服务时,会因为各种的网速问题,导致站点瞬间挂掉!那么通过一键部署,先在测试站点测试好的文件,复制到正式站点上的一个缓冲区,进行预热配置,之后再本机进行文 ...
- PHP链式操作输出excel(csv)
工作中经常会遇到产品运营让导出一些简单的比较规范的数据,这时候要是有一个简单的方法可以用就简单多了.下面是我的一个输出简单的excel(csv)的方法类,用到了链式操作.说到链式操作,在jquery中 ...
- Load Average
在Linux系统下面,有很多的命令可以查看系统的负载情况:比如top,uptime,w,示例如下: [wenchao.ren@l-cmsweb1.ops.cn1 ~]$ w 18:39:10 up 7 ...