UCMA4初体验中说到了用UCMASampleHelper帮助建立连接,现在来看自己如何建立。
前文说到了,过程分四步:创建终端、认证终端、会话建立、连接建立。
1.UserEndpoint的构造方法只有一个:
public UserEndpoint(CollaborationPlatform platform, UserEndpointSettings settings);
第一个参数是平台,第二个是配置。还记得UCMA对象基本都需要配置信息吗?而且一般都是第二个(最后一个)参数。我们先创建UserEndpointSettings的实例,UserEndpointSettings有四个构造方法,我们选择下面这个:
public UserEndpointSettings(string ownerUri, string serverName);
也就是说“由谁登录,登录到哪”。然后指定它的两个属性:
using System.Net;
userEndpointSettings.AutomaticPresencePublicationEnabled = true;
userEndpointSettings.Credential = new NetworkCredential("i", "**", "ads.assk.com");
AutomaticPresencePublicationEnabled设为true 能使对方跟踪你的状态信息。第二个是用来认证的信息,参数分别是用户名、密码、域。
然后来创建平台。CollaborationPlatform有三个构造方法:
public CollaborationPlatform(ClientPlatformSettings platformSettings); public CollaborationPlatform(ProvisionedApplicationPlatformSettings platformSettings); public CollaborationPlatform(ServerPlatformSettings platformSettings);
我们传一个ClientPlatformSettings实例:
ClientPlatformSettings clientSettings = new ClientPlatformSettings("test", SipTransportType.Tls);
SipTransportType有三个枚举值:None,Tcp,Tls。
然后终端就建好了:
UserEndpoint endPoint = new UserEndpoint(platform, userEndpointSettings);
2.和服务器连接分两步:
endPoint.Platform.BeginStartup(CallStarttupComplete, endPoint); endPoint.BeginEstablish(CallEstablishCompleted, endPoint);
需要用线程信号控制一下,第一个执行完了才能执行第二个。
private void CallStarttupComplete(IAsyncResult result) { UserEndpoint userEndPoint = result.AsyncState as UserEndpoint; CollaborationPlatform collabPlatform = userEndPoint.Platform; { collabPlatform.EndStartup(result); } } private void CallEstablishCompleted(IAsyncResult result) { { UserEndpoint messageCall = result.AsyncState as UserEndpoint; messageCall.EndEstablish(result); _callEstablishComplete.Set(); } }
3.开启会话前一篇文章说了,这里使用一下其他的构造方法:
ConversationSettings settings = new ConversationSettings(); settings.Priority = ConversationPriority.Normal; settings.Subject = "Test 01."; Conversation conversation = new Conversation(endPoint, settings);
4.开始通信的连接建立也提过:
InstantMessagingCall imCall = new InstantMessagingCall(conversation); imCall.BeginEstablish("sip:i@fd.com", null, null, CallEstablishCompleted, imCall);
建立后才可以继续其他的操作,所以也要在这里暂停。
相关推荐
exchange 2010 先决条件 UcmaRuntime 2.0安装包
UCMA应用提供对 Microsoft Lync Server增强状态信息、即时消息、电话、视频呼叫和音频/视频会议的访问和控制能力。它可用于开发机器人自动回复应用,后台控制发起IM或语音会话,消息推送机制等。 TangramUCMA 是...
Cleanup events not yet reported to the user.
OCS互动机器人,只是实现基本的IM会话功能, 代码简洁明了,供UCMA入门学习用。
您可以使用UCMA来实现它,也可以使用此存储库中的代码进行小规模入门。BotFramework的UCWA 2.0示例这是UCWA 2.0和Bot Framework Direct Line的组合示例。 有关UCWA SDK的详细信息,请参见库。 有关“直线”的详细...
活动大咖 乐打卡 红包 相亲大会 积分 乐审批 文档库 DLMS证明预约 日程 证明速递 会议室预定 乐认证 摇一摇 红包大战2017 签证查询 UCMA Outlook 统计 信息技术架构图全文共2页,当前为第1页。 DMZ/US PC端 FastDFS ...
基于 UCMA 的 Lync Server 2010/2013 的联系人管理器。 允许您集中创建联系人列表和组,然后应用于用户。
用于基于UCMA的Lync Server 2010/2013的联系人管理器。 允许您集中创建联系人列表和组,然后将其应用于用户。
provides technical information about the Unified Communications Managed API version 1.0 SDK. It is intended for application developers who are interested in creating and deploying SIP-based ...