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中最大的逻辑存储结构,与操作系统中的数据文件相相应: 基本表空间:一般指用户使用的永久性表空间,用于存储用户的永久性数据 暂时表空间: 主要用于存 ...
随机推荐
- AS技巧合集「编码技巧篇」
转载:http://www.apkbus.com/forum.php?mod=viewthread&tid=254725&extra=page%3D2%26filter%3Dautho ...
- 【poj1018】 Communication System
http://poj.org/problem?id=1018 (题目链接) 题意 要买n个产品,每个产品有m种价格和宽度(我也不知道翻译过来到底是什么?),设n个产品的宽度的最小值为B,n个产品的价格 ...
- bzoj3295: [Cqoi2011]动态逆序对(cdq分治)
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #i ...
- Visual Studio多版本进行切换的研究
最近在升级公司内部的项目到最新的开发工具Visual Studio 2015,可能在团队开发上会遇到这些问题: 1.团队成员的电脑和系统,设置安装的开发工具参差不齐 2.有些成员的Visual Stu ...
- PHPCMS \phpsso_server\phpcms\modules\phpsso\index.php、\api\get_menu.php Authkey Leakage
catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 安装phpcms的时候会强制安装它的通行证 Relevant Link: ...
- nginx中SSI问题的研究
最近感觉挺爽的,这个项目团队没有一个专门做PHP的,我是第一个进来做PHP(当然还有前端)的,哈哈,我会设计修改出适合我们业务的PHP框架,哈哈,感觉会学到很多东西的样子,前几天在组内20几个前辈面前 ...
- PHP中的一个”坑“
说一个极有可能在工作中遇到的问题——foreach的引用 foreach $arr = range(1,3); //[1,2,3] foreach($arr as &$val) { } for ...
- Spring 文件上传功能
本篇文章,我们要来做一个Spring的文件上传功能: 1. 创建一个Maven的web工程,然后配置pom.xml文件,增加依赖: <dependency> <groupId> ...
- CF 363B One Bomb(枚举)
题目链接: 传送门 One Bomb time limit per test:1 second memory limit per test:256 megabytes Description ...
- C# 开源项目一
商业协作和项目管理平台-TeamLab 网络视频会议软件-VMukti 驰骋工作流程引擎-ccflow [免费]正则表达式测试工具-Regex-Tester Windows-Phone-7-SDK E ...