Quantcast
Channel: Microsoft Unified Communications Managed API SDK forum
Viewing all 889 articles
Browse latest View live

Microsoft Lync 2010: How to create and schedule a lync 2010 meeting

$
0
0

Hi

i want to develop an application to create and schedule Microsoft Lync Server 2010 meeting using UCMA so is there any help for this.

Thanks in advance


IM Call Sample error "Unable to perform authentication of credentials"

$
0
0

I am trying to run the sample code for UCMA 3.0 SDK title InstantMessageCall, but I get the following error Unable to perform authentication of credentials.

The two methods supported are Ntlm and Kerberos, and I see that my endpoint has Mtls as protocol. Are these related? I also followed some instructions on creating a certificate for the trusted application pool in order to communicate with the FE server but I do not know how to verify.

I have an application that does however work with presence so the endpoint seems to successfully establish connections. It seems that the IM is what fails.

Application Output :

Creating User Endpoint for IMCall Sample User...

Please enter the FQDN of the Microsoft Lync Server that the IMCall Sample User endpoint is homed on => front_end_pool.myCompany.com
Please enter the User Name for IMCall Sample User (or hit the ENTER key to use current credentials)
Please enter the User Name => myUser
Enter the User Password for IMCall Sample User => myPassword
Please enter the User Domain for IMCall Sample User => myCompany.com
Please enter the User URI for IMCall Sample User in the User@Host format => myUser@myCompany.com

Platform started...
Unable to perform authentication of credentials.
Endpoint established...
The User Endpoint owned by URI: sip:myUser@myCompany.com is now established and registered.

Enter the URI of the user logged onto Microsoft Lync, in the User@Host format =>
Unhandled Exception: SupportedAuthenticationProtocols=Ntlm, Kerberos
Realm=SIP Communications Service
FailureReason=NoAuthenticatingAuthority
ErrorCode=-2146893039
Microsoft.Rtc.Signaling.AuthenticationException:Unable to perform authentication of credentials. ---> Microsoft.Rtc.Internal.Sip.AuthException: NegotiateSecurityAssociation failed, error: -2
146893039
   at Microsoft.Rtc.Internal.Sip.SipAuthenticationHelper.NegotiateSecurityAssociation(SecurityAssociationBase sa, String inputString, ContextFlags inContextAttributes, String& outputString)
   at Microsoft.Rtc.Internal.Sip.ProtocolAuth.DoProtocolOutgoingNegotiation(SecurityAssociation sa, SipMessage message, ChallengeData challengeData)
   at Microsoft.Rtc.Internal.Sip.AuthenticationControlModule.NegotiateSecurityAssociation(SecurityAssociation sa, SipMessage message, NegotiateArgs negotiateArguments)

--- End of inner exception stack trace ---
   at Microsoft.Rtc.Signaling.SipAsyncResult`1.ThrowIfFailed()
   at Microsoft.Rtc.Signaling.Helper.EndAsyncOperation[T](Object owner, IAsyncResult result)
   at Microsoft.Rtc.Collaboration.LocalEndpoint.EndEstablish(IAsyncResult result)
   at Microsoft.Rtc.Collaboration.Sample.Common.UCMASampleHelper.EndEndpointEstablish(IAsyncResult ar) in C:\Program Files\Microsoft UCMA 3.0\SDK\Core\Sample Applications\QuickStarts\Common\UCMASampleHelper.cs:line 625
   at Microsoft.Rtc.Signaling.CompletionCallbackWorkItem.Microsoft.Rtc.Signaling.IWorkitem.Process()
   at Microsoft.Rtc.Signaling.WorkitemQueue.ProcessItems()
   at Microsoft.Rtc.Signaling.SerializationQueue`1.ResumeProcessing()
   at Microsoft.Rtc.Signaling.SerializationQueue`1.ResumeProcessingCallback(Object state)
   at Microsoft.Rtc.Signaling.QueueWorkItemState.ExecuteWrappedMethod(WaitCallback method, Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)
Detected at System.Environment.get_StackTrace()
   at Microsoft.Rtc.Signaling.FailureResponseException..ctor(String message, Exception innerException, SipResponseData responseData)
   at Microsoft.Rtc.Signaling.AuthenticationException..ctor(String message, Exception innerException, SipAuthenticationProtocolsInternal authenticationProtocolsSupportedByServer, String realm, AuthenticationFailureReason failureReason, Int32 errorCode)
   at Microsoft.Rtc.Signaling.ExceptionUtilities.TryMapS4Exception(Exception s4Exception, SecurityAssociationContext securityContext, Boolean isSipEndpoint, String traceId, Object parentObject, Object childObject, RealTimeException& ex)
   at Microsoft.Rtc.Signaling.SipTransactionAsyncResult`1.Transaction_MessageSendFailed(Object sender, MessageProcessingFailedEventArgs e)
   at Microsoft.Rtc.Internal.Sip.SipCoreManager.OnMessageSendFailed(Object sender, MessageProcessingFailedEventArgs eventArgs)
   at Microsoft.Rtc.Internal.Sip.SipStack.OnMessageSentInternal(SipMessage message, Exception error)
   at Microsoft.Rtc.Internal.Sip.SingleThreadedDispatcherQueue.DispatcherCallback(Object queue)
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)

Press any key to continue . . .


PS> Get-CsTrustedApplication

Identity                   : trusted_app_pool.myCompany.com/urn:application:myTestapplication
ComputerGruus              : {trusted_server.myCompany.com sip:trusted_server.myCompany.com@myCompany.com;gruu;opaque=srvr:myTestapplication:tscNt7I7OFW2dH43cssDuQAA}
ServiceGruu                : sip:trusted_app_pool.myCompany.com@myCompany.com;gruu;opaque=srvr:myTestapplication:m84QGEhyTlK5LL8e8rOENwAA
Protocol                   : Mtls
ApplicationId              : urn:application:myTestapplication
TrustedApplicationPoolFqdn : trusted_app_pool.myCompany.com
Port                       : 10607
LegacyApplicationName      : myTestapplication

PS> Get-CsTrustedApplicationEndpoint

Identity               : CN={02f81c7f-c02c-40db-b2ee-aa0e0d6fe1dd},CN=Application Contacts,CN=RTC Service,CN=Services,CN=Configuration,DC=myCompany,DC=com
RegistrarPool          : front_end_pool.myCompany.com
HomeServer             : CN=Lc Services,CN=Microsoft,CN=1:2,CN=Pools,CN=RTC Service,CN=Services,CN=Configuration,DC=myCompany,DC=com
OwnerUrn               : urn:application:myTestapplication
SipAddress             : sip:myUser@myCompany.com
DisplayName            : IM Bot
DisplayNumber          :
LineURI                :
PrimaryLanguage        : 0
SecondaryLanguages     : {}
EnterpriseVoiceEnabled : True
Enabled                : True


Any clues or suggestions will help. Thanks in advance.

Whats UCMA 3.0 Voicexml Browser default audio format?

$
0
0

Currently, I am developing a ucma 3.0 vxml application. The following is some code in the VoiceXml document.

<form> <record  name="msg" beep="true" maxtime="10s"  dtmfterm="true" type="audio/x-wav">
      
<prompt timeout="5s">
         Record a message after the beep.
      
</prompt>
      
<noinput>
         I didn't hear anything, please try again.
      
</noinput>
    
</record>

 
<block>
   
<submit next="http://SomeServer//SomePage.aspx"  enctype="multipart/form-data" method="post" namelist="msg"/>
 
</block>    

</form>

At SomeServer/SomePage.aspx , save the posted recording to a wav file.whats the format of the saved wav file, 8KHz/8-bit or 8KHz/16-bit or 16KHz/16-bit?

Voicexml specification 2.0 requires that all platforms must support the playing and recording audio formats specified below:

  • Raw (headerless) 8kHz 8-bit mono mu-law [PCM] single channel. (G.711) -- audio/basic (from [RFC1521])
  • Raw (headerless) 8kHz 8 bit mono A-law [PCM] single channel. (G.711) -- audio/x-alaw-basic
  • WAV (RIFF header) 8kHz 8-bit mono mu-law [PCM] single channel. -- audio/x-wav
  • WAV (RIFF header) 8kHz 8-bit mono A-law [PCM] single channel. -- audio/x-wav

I need to get 16KHz 16-bit mono pcm recording? Is this possible?(UCMA 3.0 VoiceXml application)

How to accept PIN as an authentication method for a ucma application without the workflow sdk?

$
0
0

Would like to see maybe a sample implementation in a ucma bot that authenticates a caller with a pin just with the use a the core ucma api (without using the workflow sdk)

I tried hooking it up with the ToneReceived event of the ToneController but its only able to know the first digit of the series of numbers im trying to press on the dialer.

Anyone seen such implementation before? please point me to it...

Thanks!

Where is the VoiceXML namespace in the Microsoft Speech Platform 11 SDK?

$
0
0

I've been working with Microsoft Speech Platform 10.2 SDK for a while, and I've included a reference to the VoiceXML DLL included in the SDK. I've inherited the Browser class, and have a working VoiceXML application.

I was looking at the newest version of the speech platform sdk (version 11) and it doesn't seem to include any VoiceXml namespaces or DLLs.  I used reflector to check the namespaces, and I can't find any voice xml dlls in the SDK folders.

What happened to the VoiceXML namespace in v11 of the speech platform?  


http://donahoo-development.com

Contact object in AD for ApplicationEndPoint UCMA 2.0

$
0
0

Where is the contact object for an ApplicationEndpoint created in AD? According to the documentation each ApplicationEndpoint It is represented by a Contact object in Active Directory. Have created a ApplicationEndpoint but can't find the corresponding ContactObject anywhere in AD.

Search for a contact using UCMA 3.0

$
0
0

Hi All,

I'm new to UCMA and have some questions. Ultimately, I would want to search for all available contact in my Company using UCMA 3.0, something similar to Lync Client search by name or email. If you have some sample code would be very useful to me, else I hope you can point me at the right direction. Thank you.

Simon

What are Limitations of ExpiryTime of ConferenceScheduleInformation?

$
0
0

What is the upper limit (max date) for ConferenceScheduleInformation.ExpiryTime property of Microsoft.Rtc.Collaboration.ConferenceManagement? And what if I have given ConferenceScheduleInformation.ExpiryTime=null?

Do we have any way through which we can generate conference URL that never expires?



What integration capabilities are there for Lync on iOS and Android?

$
0
0

Is UCMA available for iOS and Android as it is with Windows?

Can I use UI suppression?

Any suggestions are much appreciated.

Thank you,

Tim

Solution architecture

$
0
0

Hi

I'm creating an informtion board application for my workplace to aggregate and display information from different systems. The application will connect to Lync via UCMA to retrieve presence information and connect to another system to retreive information via HTTP and XML. This should be displayed on one webpage for easy consumption.

Does it seem sensible and possible to create a solution with four projects: one for the UCMA app (targeting .NET 3.5), one for retrieving information from the other system, one for a asp.net web api to expose the information, and one for the website that will consume and display the information?

Regards Anders


Problem while joining meeting through Lync meeting URL generated by Lync Server 2010.

$
0
0

Whenever I try to join lync meeting (by accessing generated meeting url in browser) through Meeting Url generated using Lync Server 2010, it always shows following error message (also shown in image bellow)

"Sorry, something went wrong, and we can't get you into the meeting."

Lync Meeting Joining Error

Thanks.

Can I use UCMA4.0 SDK for retrieving presence information from Microsoft Lync 2010?

$
0
0

Hi,

     Can I use  UCMA4.0 SDK for retrieving presence information from Microsoft Lync 2010?

Thanks in advance.

Cannot install Unified Communications Managed API 4.0 for Exchange 2013 Preview

$
0
0

I am attempting to install Exchange 2013 Preview in my test environment.  For pre-requests I must install UCMA 4.0.  Upon start-up I get error due to  "Server Media Experience" not being installed on my 2012 Server (with GUI).

What does this mean?  Where do I install "Server Media Experience" in Server Manager?


Rule One: The doctor always lies

Lync Bot UCMA Application

$
0
0

Hi,

I need to talk to Lync 2010 from my dot net application.

Question is this:  Server A (application server) needs to communicate with the trusted lync application on Server B to launch conversations users will respond to the bot and responses need to be sent back to Server A.  Most of the samples I see are around console applications which won't be ideal. 

please help me in acheiving thisRegards,

kumar V.

How to delete a presence that is expireType="static" - UCMA 3.0

$
0
0

I got a Lync user that has a presence state with expireType set to "static".

If the user manually change the presence to "Available" and then click on "Reset Status" it will set it self to back to a static presence.

In UCMA, I am trying to delete this presence but with no luck.

Is it possible to delete does presence that has expireType="static" ?

Kind regards

 Kim

Lync logging trace that has the following output:

<category name="state" instance="1" publishTime="2012-10-11T13:06:11.530" container="2" version="42" expireType="user">
<state xsi:type="aggregateState" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2006/09/sip/state"><availability>6500</availability><activity><custom LCID="1033" xmlns="http://schemas.microsoft.com/2006/09/sip/state">In a mobile call</custom></activity><delimiter xmlns="http://schemas.microsoft.com/2006/09/sip/commontypes" /><timeZoneBias>-120</timeZoneBias><timeZoneName>Romance Daylight Time</timeZoneName><timeZoneAbbreviation>Romance Daylight Time</timeZoneAbbreviation><device>computer</device><end xmlns="http://schemas.microsoft.com/2006/09/sip/commontypes" /></state>
</category>

<category name="state" instance="0" publishTime="2012-10-11T10:29:02.707" container="2" version="8" expireType="static">
<state xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2006/09/sip/state" xsi:type="phoneState"><availability>6500</availability><activity maxAvailability="8999" minAvailability="6500"><custom LCID="1033">In a mobile call</custom></activity></state>
</category>

<category name="state" instance="0" publishTime="2012-10-11T13:13:25.540" container="3" version="1" expireType="static">
<state xsi:type="aggregateState" lastActive="2012-10-11T13:13:07" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2006/09/sip/state"><availability>18000</availability></state>
</category>



Handling "invite a contact" at the Lync client when that client is BackToBacked into a conference hosted by a UCMA application.

$
0
0

I'm working on a UCMA 3.0 application that records calls between certain users by putting them into a conference and recording that conference.  If A is a party whose calls should be recorded an MSPL application will see an inbound or outbound request involving A and route that request to the UCMA application.  The UCMA application creates an ad-hoc conference, arranges a BackToBackCall between the calling party and the conference and a second BackToBackCall between the called party and the conference.  The Lync client at both called and calling parties desktop appears as though it’s in a two party call with the other endpoint. 

I’m having problems trying to support the functionality where either party can invite a third party to the call resulting in a conference.  Using the sip snooper I can see the Invite with conference details being sent from the client that invites the third party to the party they were already in a call with, the invite is addressed to the UCMA application but is rejected with a reason of “Conference escalation is not supported by application”.  I never see a ConferenceInvitationReceived event raised, I have wired a handler.  Some other things I’ve tried are manipulating the SupportedMimePartContentTypes for the application endpoint to advertise that it can support Content-Type: application/ms-conf-invite+xml.  I’ve also made sure that call the call legs involved in the BackToBackCalls have headers that indicate support for ms-conf-invite.

Any ideas what I’ve missed?  Or has anyone implemented similar functionality a different way?

How to update conference details using UCMA 3.0?

$
0
0

I've created a conference using UCMA 3.0,

Now what I want to do is to modify conference details that I've created previously.

I've tried

private void ModifyConference(string confId) { // The base conference settings object, used to set the policies for the conference. ConferenceScheduleInformation conferenceScheduleInformation = new ConferenceScheduleInformation(); // An open meeting (participants can join who are not on the list), // but requiring authentication (no anonymous users allowed.) conferenceScheduleInformation.ConferenceId = confId; _callerEndpoint.ConferenceServices.BeginUpdateConference(conferenceScheduleInformation, EndUpdateConference, _callerEndpoint.ConferenceServices); _waitForConferenceUpdating.WaitOne(); } }

private void EndUpdateConference(IAsyncResult ar)
        {
            ConferenceServices confSession = ar.AsyncState as ConferenceServices;
            try
            {
                confSession.EndUpdateConference(ar);
            }
            catch (Exception ex)
            {

            }
            _waitForConferenceUpdating.Set();
        }

When I execute this code it is throwing an Exception

{"The request failed with reason: invalidVersion."}

Frequently Asked Questions for UCMA

$
0
0

Q:  Can I perform anonymous web chat with UCMA?

A:  Yes. Take a look at the Contact Center reference application that is in the UCMA SDK. It demonstrates how to build a web service on top of UCMA.

Q: Is there a UCMA SDK for mobile devices?

A: Not specifically, but you can create a web service that communicates with the mobile device.


-- How To Ask a Question: http://support.microsoft.com/kb/555375 -- This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm

Presence status not updating

$
0
0

The PresenceView is created with an application endpoint which is manually provisioned. It is fed with with three targets and all are subscribed. But I only recieve their first notification. After that, nothing happens. The same is the case with polling. The NotificationRecieved event is not firing after the first notification. The Lync Event Log show no errors and no expections are thrown.

My setup is a virtual environment with a DC, Lync Server, and Developer machine which also acts as an application pool. Everything looks okay.

Below are included some samples of my code. My solution consists of two projects: a small console application and a project with the lync code. It is based on the SubscribePresenceView sample solution from the UCMA code samples, which updates the presence state just fine, although it uses a user endpoint instead.

Run method from my RemotePresenceView class.

        public void Run()
        {
            _helper = new Helper(new ConsoleLogger());
            _applicationEndpoint = _helper.CreateApplicationEndpoint();
                        

            var viewSettings = new RemotePresenceViewSettings();
            viewSettings.SubscriptionMode = RemotePresenceViewSubscriptionMode.Default;
            _presenceView = new RemotePresenceView(_applicationEndpoint, viewSettings);

            List<RemotePresentitySubscriptionTarget> targets = new List<RemotePresentitySubscriptionTarget>();
            targets.Add(new RemotePresentitySubscriptionTarget("sip:mortenl@mupersan.local"));
            targets.Add(new RemotePresentitySubscriptionTarget("sip:finnl@mupersan.local"));
            targets.Add(new RemotePresentitySubscriptionTarget("sip:andersl@mupersan.local"));

            this.WireUpHandlersForView(_presenceView);
            
            _presenceView.StartSubscribingToPresentities(targets);
        }

Handle notification delegate method:

        private void RemotePresenceView_NotificationReceived(object sender, RemotePresentitiesNotificationEventArgs e)
        {
            // A RemotePresentityNotification will contain all the
            // categories for one user; Notifications can contain notifications
            // for multiple users.

            foreach (RemotePresentityNotification notification in e.Notifications)
            {
               Console.WriteLine("\nReceived a Notification for user "+ notification.PresentityUri + ".");

               // If a category on notification is null, the category
               // was not present in the notification. This means there were no
               // changes in that category.



               if (notification.AggregatedPresenceState != null)
               {
                   Console.WriteLine("Aggregate State = " + notification.AggregatedPresenceState.Availability + ".");
               }

               if (notification.PersonalNote != null)
               {
                   Console.WriteLine("PersonalNote: " + notification.PersonalNote.Message + ".");
               }

               if (notification.ContactCard != null)
               {
                   // A ContactCard contains many properties; only display
                   // some.
                   ContactCard contactCard = notification.ContactCard;
                   Console.WriteLine("ContactCard Company: " + contactCard.Company + ".");
                   Console.WriteLine("ContactCard DisplayName: " + contactCard.DisplayName + ".");
                   Console.WriteLine("ContactCard EmailAddress: " + contactCard.EmailAddress + ".");
               }           
            }
        }

Regards Anders


RemotePresenceView (Persistent mode) only receives one notification then nothing more happens.

$
0
0


I have run the sample Subscribe presenceview which worked great, but I need to do the same with an Application endpoint against target users.

So I modified the Manual provisioning sample and added the code for subscribing to presence for a target user, the code is the same as the working presenceview example.

The problem is that I only receive the initial presence notification when I use Persistent mode. No further notifications after that. (Polling mode with 5 minutes interval works though), but persistent does not notify me when I change the presence of the target.


The only difference from the working Presenceview example is that I am using an Application Endpoint in a trusted application pool in my example:


********************************************************
*                                                       *
*   Copyright (C) Microsoft. All rights reserved.       *
*                                                       *
********************************************************/

// .NET namespaces
using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

// UCMA namespaces
using Microsoft.Rtc.Collaboration;
using Microsoft.Rtc.Collaboration.Presence;
using Microsoft.Rtc.Signaling;

// UCMA samples namespaces
using Microsoft.Rtc.Collaboration.Sample.Common;

namespace Microsoft.Rtc.Collaboration.Sample.ManualProvisioning
{
    public class UCMASampleManualProvisioning
    {
        #region Locals
        #region UCMA 3.0 Core Classes
        /// <summary>
        /// The settings typically used for creating a CollaborationPlatform
        /// instance to be used for manually creating ApplicationEndpoints.
        /// </summary>
        private ServerPlatformSettings _platformSettings;

        /// <summary>
        /// The highest-level API in UCMA, responsible for managing connections
        /// between servers, establishing trust with other servers and
        /// providing control over all the endpoints bound to it.
        /// </summary>
        private CollaborationPlatform _platform;

        /// <summary>
        /// The settings typically used for creating an ApplicationEndpoint.
        /// </summary>
        private ApplicationEndpointSettings _endpointSettings;

        /// <summary>
        /// The endpoint designed to be globally trusted by other server
        /// components.
        /// </summary>
        private ApplicationEndpoint _endpoint;
        #endregion

        #region Configuration Settings
        /// <summary>
        /// The part of the user agent string that identifies the application.
        /// </summary>
        private const string _applicationUserAgent = "UCMASampleApp";

        /// <summary>
        /// Fully Qualified Domain Name (FQDN) of the computer in the trusted
        /// application pool.
        /// </summary>
        private string _applicationHostFQDN;

        /// <summary>
        /// Port assigned to the trusted application.
        /// </summary>
        private int _applicationHostPort;

        /// <summary>
        /// GRUU assigned to this computer for the trusted application.
        /// </summary>
        private string _computerGRUU;

        /// <summary>
        /// Friendly name of the certificate identifying this computer.
        /// </summary>
        /// <remarks>
        /// See http://msdn.microsoft.com/en-us/library/ms788967.aspx for help
        /// viewing certificates with the MMC snap-in.
        /// </remarks>
        private string _certificateFriendlyName;

        /// <summary>
        /// Certificate identifying this computer.
        /// </summary>
        private X509Certificate2 _certificate;

        /// <summary>
        /// SIP URI assigned to the trusted application endpoint.
        /// </summary>
        private string _endpointOwnerURI;

        /// <summary>
        /// FQDN of the registrar pool to which this trusted application
        /// endpoint is assigned.
        /// </summary>
        private string _registrarFQDN;

        /// <summary>
        /// Port of the registrar pool to which this trusted application
        /// endpoint is assigned.
        /// </summary>
        private int _registrarPort;

        private RemotePresenceView _persistentView;
        private RemotePresenceView _pollingView;
        private RemotePresentitySubscriptionTarget _target;

        #endregion
        #endregion

        #region Methods
        /// <summary>
        /// Instantiate and run the ManualProvisioning quickstart.
        /// </summary>
        /// <param name="args">unused</param>
        public static void Main(string[] args)
        {
            UCMASampleManualProvisioning ucmaSampleManualProvisioning
                = new UCMASampleManualProvisioning();
            ucmaSampleManualProvisioning.Run();
        }
      
        /// <summary>
        /// Retrieves the application configuration and begins starting up the
        /// platform.
        /// </summary>
        private void Run()
        {
            // Prompt for the settings necessary to initialize the
            // CollaborationPlatform and the ApplicationEndpoint if they are
            // not declared in App.config.
            // TODO (Left to the reader): Input sanitization on the
            // collected parameters.
            _applicationHostFQDN = UCMASampleHelper.PromptUser(
                "Please enter the FQDN assigned to this computer in the trusted application pool => ",
                "TrustedAppComputerFQDN");
            if (string.IsNullOrEmpty(_applicationHostFQDN))
            {
                UCMASampleHelper.WriteErrorLine(
                    "No FQDN was found in App.config or input by the user.");
            }
            string inputPort = UCMASampleHelper.PromptUser(
                "Please enter the port assigned to this trusted application => ",
                "TrustedAppPort");
            if (!int.TryParse(inputPort, out _applicationHostPort))
            {
                UCMASampleHelper.WriteErrorLine(
                    "Port could not be parsed from App.config or from input by the user.");
            }
            _computerGRUU = UCMASampleHelper.PromptUser(
                "Please enter the GRUU assigned to this computer for this trusted application => ",
                "TrustedAppComputerGRUU");
            if (string.IsNullOrEmpty(_computerGRUU))
            {
                UCMASampleHelper.WriteErrorLine("No GRUU was found in App.config or input by the user.");
            }
            _certificateFriendlyName = UCMASampleHelper.PromptUser(
                "Please enter the friendly name of the certificate identifying this computer => ",
                "CertificateFriendlyName");
            if (string.IsNullOrEmpty(_certificateFriendlyName))
            {
                UCMASampleHelper.WriteErrorLine(
                    "No certificate friendly name was found in App.config or input by the user.");
            }
            _certificate = UCMASampleHelper.GetLocalCertificate(_certificateFriendlyName);
            if (_certificate == null)
            {
                UCMASampleHelper.WriteErrorLine("Certificate with friendly name '" + _certificateFriendlyName
                    + "' could not be found in computer account Personal certificate store.");
            }
            _endpointOwnerURI = UCMASampleHelper.PromptUser(
                "Please enter the SIP URI assigned to this trusted application endpoint => ",
                "TrustedAppEpOwnerURI");
            if (string.IsNullOrEmpty(_endpointOwnerURI))
            {
                UCMASampleHelper.WriteErrorLine("No SIP URI was found in App.config or input by the user.");
            }
            _registrarFQDN = UCMASampleHelper.PromptUser(
                "Please enter the FQDN of the registrar pool  to which this endpoint is assigned => ",
                "RegistrarFQDN");
            if (string.IsNullOrEmpty(_registrarFQDN))
            {
                UCMASampleHelper.WriteErrorLine(
                    "No registrar pool FQDN was found in App.config or input by the user.");
            }
            string inputRegistrarPort = UCMASampleHelper.PromptUser(
                "Please enter the port used by the registrar pool to which this endpoint is assigned => ",
                "RegistrarPort");
            if (!int.TryParse(inputRegistrarPort, out _registrarPort))
            {
                UCMASampleHelper.WriteErrorLine(
                    "Registrar port could not be parsed from App.config or from input by the user.");
            }

            try
            {
                // Create the CollaborationPlatform using the
                // ServerPlatformSettings.
                _platformSettings = new ServerPlatformSettings(_applicationUserAgent,
                    _applicationHostFQDN,
                    _applicationHostPort,
                    _computerGRUU,
                    _certificate);
                _platform = new CollaborationPlatform(_platformSettings);

                // Initialize and startup the platform. EndPlatformStartup()
                // will be called when the platform finishes starting up.
                UCMASampleHelper.WriteLine("Starting platform...");
                _platform.BeginStartup(PlatformStartupCompleted, _platform);
            }
            catch (ArgumentNullException argumentNullException)

      ....
      ....

      finally
            {
                // Wait for the sample to finish before shutting down the
                // platform and returning from the main thread.
                UCMASampleHelper.WaitForSampleFinish();

                // It is possible the platform was never created due to issues
                // collecting configuration parameters.
                if (_platform != null)
                {
                    // Shutdown the platform, thereby terminating any attached
                    // endpoints.
                    UCMASampleHelper.WriteLine("Shutting down the platform...");
                    _platform.BeginShutdown(PlatformShutdownCompleted, _platform);
                }
            }
        }

        /// <summary>
        /// Acquire settings necessary for sample to run.
        /// </summary>
        private void AcquireSettings()
        {
        }
        #endregion

        #region Callback Delegates
        /// <summary>
        /// Callback from <code>BeginStartup</code> method on platform.
        /// </summary>
        /// <param name="result">
        /// Status of the platform startup operation.
        /// </param>
        private void PlatformStartupCompleted(IAsyncResult result)
        {
            // Extract the platform that was passed in as the state argument to
            // the BeginStartup() method.
            CollaborationPlatform platform = result.AsyncState as CollaborationPlatform;

            if (platform == null)
            {
                UCMASampleHelper.WriteErrorLine("CollaborationPlatform not passed into BeginStartup() method.");
                UCMASampleHelper.FinishSample();
                return;
            }

            try
            {
                // Determine whether the startup operation completed
                // successfully.
                platform.EndStartup(result);

                UCMASampleHelper.WriteLine("Platform has been started.");
            }

           }
          
           ......
          
            try
            {
                // Create the ApplicationEndpointSettings.
                _endpointSettings = new ApplicationEndpointSettings(_endpointOwnerURI,
                    _registrarFQDN,
                    _registrarPort);

                // Create the ApplicationEndpoint from the
                // ApplicationEndpointSettings and bind it to the platform.
                _endpoint = new ApplicationEndpoint(platform, _endpointSettings);

                // Bind an event handler to notify when the endpoint changes
                // state.
                _endpoint.StateChanged += new EventHandler<LocalEndpointStateChangedEventArgs>(
                    _endpoint_StateChanged);

                // Establish the endpoint so that it can receive incoming calls
                // and conference invitations. EndEndpointEstablish()  will be
                // called when the endpoint finishes establishment.
                _endpoint.BeginEstablish(EndpointEstablishmentCompleted, _endpoint);

                UCMASampleHelper.WriteLine("Endpoint has been established.");
            }
            catch (ArgumentNullException argumentNullException)
     .....
        }

        /// <summary>
        /// Helper to wire up important event handlers for a RemotePreenceView.
        /// </summary>
        /// <param name="view">View to add event handlers to.</param>
        private void WireUpHandlersForView(RemotePresenceView view)
        {
            Console.WriteLine("\nWiring up handlers for view: " + view.ApplicationContext);
            view.SubscriptionStateChanged += RemotePresenceView_SubscriptionStateChanged;
            view.PresenceNotificationReceived += RemotePresenceView_NotificationReceived;
        }

        private void subscribeToPresence(LocalEndpoint ep)
        {
            ep.RemotePresence.PresenceSubscriptionCategories =
                new string[] { PresenceCategoryNames.ContactCard, PresenceCategoryNames.State };

            var persistentSettings = new RemotePresenceViewSettings();
            persistentSettings.SubscriptionMode = RemotePresenceViewSubscriptionMode.Default;
            _persistentView = new RemotePresenceView(ep, persistentSettings);
            _persistentView.ApplicationContext = "Persistent View";

            // Wire up event handlers for the view
            this.WireUpHandlersForView(_persistentView);

            // Create a RemotePresenceView with a polling subscription mode
            // This type of view can represent a list of people
            // on the To: line of an e-mail, for example.
            var pollingSettings = new RemotePresenceViewSettings();
            pollingSettings.SubscriptionMode = RemotePresenceViewSubscriptionMode.Polling;
            // The line below is not necessary; PollingInterval has a default
            // (and minimum) value of 5 minutes.
            pollingSettings.PollingInterval = TimeSpan.FromMinutes(5);
            _pollingView = new RemotePresenceView(ep, pollingSettings);
            _pollingView.ApplicationContext = "Polling View";

            // Wire up event handlers for the view
            this.WireUpHandlersForView(_pollingView);

            Console.WriteLine("\nChanging Polling View's category filter to only include Note.");
            _pollingView.SetPresenceSubscriptionCategoriesForPolling(
                new string[] { PresenceCategoryNames.Note });

            try
            {
                // This constructor does very basic validation on the uri
                _target = new RemotePresentitySubscriptionTarget("sip:kari@tmos.local");
            }
            catch (ArgumentException argumentException)
            {
                // ArgumentException will be thrown if the parameter used to
                // create the RemotePresentitySubscriptionTarget is an
                // invalid sip Uri.

                // TODO (Left to the reader): Error handling code to either
                // retry creating the target with corrected parameters, log
                // the error for debugging or gracefully exit the program.
                Console.WriteLine(argumentException.ToString());
                throw;
            }

            // Both Views will try to subscribe to the specified user
            // Note: if the target is a not a real user, these operations will
            // "succeed", but the StateChanged notifications will indicate the
            // subscription went to a Terminated state.
            _persistentView.StartSubscribingToPresentities(new RemotePresentitySubscriptionTarget[] { _target });
            _pollingView.StartSubscribingToPresentities(new RemotePresentitySubscriptionTarget[] { _target });

            // There is no callback for the StartSubscribingToPresentities
            // operation because subscriptions to multiple targets can
            // complete at different times. Completion or failure of the
            // subscription can be monitored through the
            // SubscriptionStateChanged event handler,
            // RemotePresenceView_NotificationReceived.

            UCMASampleHelper.PauseBeforeContinuing("Press ENTER to unsubscribe.");

            Console.WriteLine("\nBoth Views are terminating any subscriptions to user: ");
          
        }

        private void RemotePresenceView_NotificationReceived(object sender, RemotePresentitiesNotificationEventArgs e)
        {
            // Extract the RemotePresenceView that received the notification.
            RemotePresenceView view = sender as RemotePresenceView;
            // A RemotePresentityNotification will contain all the
            // categories for one user; Notifications can contain notifications
            // for multiple users.
            foreach (RemotePresentityNotification notification in e.Notifications)
            {
                Console.WriteLine("\nView: " + view.ApplicationContext
                    + " Received a Notification for user "
                    + notification.PresentityUri + ".");

                // If a category on notification is null, the category
                // was not present in the notification. This means there were no
                // changes in that category.
                if (notification.AggregatedPresenceState != null)
                {
                    Console.WriteLine("Aggregate State = " + notification.AggregatedPresenceState.Availability + ".");
                }

                if (notification.PersonalNote != null)
                {
                    Console.WriteLine("PersonalNote: " + notification.PersonalNote.Message + ".");
                }

                if (notification.ContactCard != null)
                {
                    // A ContactCard contains many properties; only display
                    // some.
                    ContactCard contactCard = notification.ContactCard;
                    Console.WriteLine("ContactCard Company: " + contactCard.Company + ".");
                    Console.WriteLine("ContactCard DisplayName: " + contactCard.DisplayName + ".");
                    Console.WriteLine("ContactCard EmailAddress: " + contactCard.EmailAddress + ".");
                }
            }

        }

        private void RemotePresenceView_SubscriptionStateChanged(object sender, RemoteSubscriptionStateChangedEventArgs e)
        {
            // Extract the view that raised the event.
            RemotePresenceView view = sender as RemotePresenceView;
            // The event args can contain multiple StateChanged notifications
            foreach (KeyValuePair<RealTimeAddress, RemotePresentityStateChange> stateChanged in e.SubscriptionStateChanges)
            {
                Console.WriteLine("\nView: " + view.ApplicationContext
                    + "; SubscriptionState for user: "
                    + stateChanged.Key /* uri of subscription target */
                    + " has changed from: " + stateChanged.Value.PreviousState
                    + " to: " + stateChanged.Value.State + ".");
            }
        }


        /// <summary>
        /// Callback from <code>BeginEstablish</code> method on endpoint.
        /// </summary>
        /// <param name="result">
        /// Status of the endpoint establishment operation.
        /// </param>
        private void EndpointEstablishmentCompleted(IAsyncResult result)
        {
            // Extract the endpoint that was passed in as the state argument to
            // the BeginEstablish() method.
            ApplicationEndpoint endpoint = result.AsyncState as ApplicationEndpoint;

            if (endpoint == null)
            {
                UCMASampleHelper.WriteErrorLine("ApplicationEndpoint not passed into BeginEstablish() method.");
                UCMASampleHelper.FinishSample();
                return;
            }

            try
            {
                // Determine whether the establish operation completed
                // successfully.
                endpoint.EndEstablish(result);

                subscribeToPresence(endpoint);

                Console.Write("Subscribed....enter to continue.");
                Console.ReadKey();

                _persistentView.StartUnsubscribingToPresentities(new string[] { "sip:kari@tmos.local" });
                _pollingView.StartUnsubscribingToPresentities(new string[] { "sip:kari@tmos.local" });
                // Endpoint state change event handler will log the successful
                // establishment of the endpoint.
                UCMASampleHelper.FinishSample();
            }
            catch (ConnectionFailureException connectionFailureException)
            {
                // ConnectionFailureException will be thrown when no connection
                // can be made to the server.
                // TODO (Left to the reader): Error handling code to either
                // retry establishing the endpoint, log the error for debugging
                // or gracefully exit the program.
                UCMASampleHelper.WriteException(connectionFailureException);
                UCMASampleHelper.FinishSample();
            }
            catch (OperationFailureException operationFailureException)
            {
                // OperationFailureException will be thrown if the retrieval of
                // in-band provisioning data fails.
                // TODO (Left to the reader): Error handling code to either
                // retry establishing the endpoint, log the error for debugging
                // or gracefully exit the program.
                UCMASampleHelper.WriteException(operationFailureException);
                UCMASampleHelper.FinishSample();
            }
            catch (RegisterException registerException)
            {
                // RegisterException will be thrown if the SIP REGISTER
                // operation fails.
                // TODO (Left to the reader): Error handling code to either
                // retry establishing the endpoint, log the error for debugging
                // or gracefully exit the program.
                UCMASampleHelper.WriteException(registerException);
                UCMASampleHelper.FinishSample();
            }
            catch (AuthenticationException authenticationException)
            {
                // AuthenticationException will be thrown if general
                // authentication-related problem occur.
                // TODO (Left to the reader): Error handling code to either
                // retry establishing the endpoint, log the error for debugging
                // or gracefully exit the program.
                UCMASampleHelper.WriteException(authenticationException);
                UCMASampleHelper.FinishSample();
            }
            catch (OperationTimeoutException operationTimeoutException)
            {
                // OperationTimeoutException will be thrown if the registrar
                // server does not respond to REGISTER request.
                // TODO (Left to the reader): Error handling code to either
                // retry establishing the endpoint, log the error for debugging
                // or gracefully exit the program.
                UCMASampleHelper.WriteException(operationTimeoutException);
                UCMASampleHelper.FinishSample();
            }
            catch (RealTimeException realTimeException)
            {
                // RealTimeException will be thrown if the endpoint establish
                // operation fails due to some other issue.
                // TODO (Left to the reader): Error handling code to either
                // retry establishing the endpoint, log the error for debugging
                // or gracefully exit the program.
                UCMASampleHelper.WriteException(realTimeException);
                UCMASampleHelper.FinishSample();
            }
        }
      
        /// <summary>
        /// Callback from <code>BeginShutdown</code> method on platform.
        /// </summary>
        /// <param name="result">
        /// Status of the platform shutdown operation.
        /// </param>
        private void PlatformShutdownCompleted(IAsyncResult result)
        {
            // Extract the platform that was passed in as the state argument to
            // the BeginShutdown() method.
            CollaborationPlatform platform = result.AsyncState as CollaborationPlatform;

            if (platform == null)
            {
                UCMASampleHelper.WriteErrorLine(
                    "CollaborationPlatform not passed into BeginShutdown() method.");
                UCMASampleHelper.FinishSample();
                return;
            }

            // Determine whether the shutdown operation completed
            // successfully.
            platform.EndShutdown(result);

            UCMASampleHelper.WriteLine("The platform is now shut down.");
        }
        #endregion

        #region Event Handlers
        /// <summary>
        /// Record the endpoint state transitions to the console.
        /// </summary>
        /// <param name="sender">Endpoint that saw its state change.</param>
        /// <param name="e">Data about the endpoint state change event.</param>
        private void _endpoint_StateChanged(object sender, LocalEndpointStateChangedEventArgs e)
        {
            // Extract the endpoint that sent the state change event.
            ApplicationEndpoint endpoint = sender as ApplicationEndpoint;

            UCMASampleHelper.WriteLine("Endpoint (" + endpoint.OwnerUri
                + ") has changed state. The previous endpoint state was '"
                + e.PreviousState + "' and the current state is '" + e.State + "'.");
        }
        #endregion
    }
}

Viewing all 889 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>