Beispiel #1
0
 public static Task UpdateGroupAsync(this
                                     ContactGroupServices cgs, Group group)
 {
     return(Task.Factory.FromAsync(
                cgs.BeginUpdateGroup, cgs.EndUpdateGroup,
                group, null));
 }
Beispiel #2
0
 public static Task UpdateContactAsync(this
                                       ContactGroupServices cgs, Contact contact)
 {
     return(Task.Factory.FromAsync(
                cgs.BeginUpdateContact, cgs.EndUpdateContact,
                contact, null));
 }
Beispiel #3
0
 public static Task AddContactAsync(this
                                    ContactGroupServices cgs, string contactUri)
 {
     return(Task.Factory.FromAsync(
                cgs.BeginAddContact, cgs.EndAddContact,
                contactUri, null));
 }
Beispiel #4
0
 public static Task <Contact> GetCachedContactAsync(this
                                                    ContactGroupServices cgs, string contactUri)
 {
     return(Task <Contact> .Factory.FromAsync(
                cgs.BeginGetCachedContact, cgs.EndGetCachedContact,
                contactUri, null));
 }
Beispiel #5
0
 public static Task <Group> GetCachedGroupAsync(this
                                                ContactGroupServices cgs, int groupId)
 {
     return(Task <Group> .Factory.FromAsync(
                cgs.BeginGetCachedGroup,
                cgs.EndGetCachedGroup, groupId, null));
 }
Beispiel #6
0
        // Callback triggered when contact is deleted
        private void EndDeleteContactCompleted(IAsyncResult ar)
        {
            ContactGroupServices services = ar.AsyncState as ContactGroupServices;

            try
            {
                services.EndDeleteContact(ar);
                Console.WriteLine("Contact {0} was successfully deleted.", _remoteUserUri);
            }
            catch (PublishSubscribeException psex)
            {
                Console.WriteLine("Delete Contact failed due to exception: {0}", psex.ToString());
            }
            catch (InvalidOperationException ioex)
            {
                Console.WriteLine("Delete Contact failed due to exception: {0}", ioex.ToString());
            }
            catch (OperationFailureException ofex)
            {
                Console.WriteLine("Delete Contact failed due to exception: {0}", ofex.ToString());
            }
            catch (RealTimeException rtex)
            {
                Console.WriteLine("Delete Contact failed due to exception: {0}", rtex.ToString());
            }
            finally
            {
                services.BeginDeleteGroup(_groupId, EndDeleteGroupCompleted,
                                          _userEndpoint.ContactGroupServices);
            }
        }
Beispiel #7
0
        // Callback triggered when contact is added
        private void EndAddContactCompleted(IAsyncResult ar)
        {
            ContactGroupServices services = ar.AsyncState as ContactGroupServices;

            try
            {
                services.EndAddContact(ar);
                Console.WriteLine("Contact " + _remoteUserUri + " was added to group " + _groupName);
            }
            catch (PublishSubscribeException psex)
            {
                Console.WriteLine("Could not add contact due to exception: {0}", psex.ToString());
            }
            catch (InvalidOperationException ioex)
            {
                Console.WriteLine("Add Contact failed due to exception: {0}", ioex.ToString());
            }
            catch (OperationFailureException ofex)
            {
                Console.WriteLine("Add Contact failed due to exception: {0}", ofex.ToString());
            }
            catch (RealTimeException rtex)
            {
                Console.WriteLine("Add Contact failed due to exception: {0}", rtex.ToString());
            }
        }
Beispiel #8
0
        // Callback triggered when group is deleted
        private void EndDeleteGroupCompleted(IAsyncResult ar)
        {
            ContactGroupServices services = ar.AsyncState as ContactGroupServices;

            try
            {
                services.EndDeleteGroup(ar);
                Console.WriteLine("Group {0} was successfully deleted.", _groupName);
                _waitForGroupDeleted.Set();
            }
            catch (PublishSubscribeException psex)
            {
                Console.WriteLine("Group {0} could not be deleted due to exception: {1}",
                                  _groupName, psex.ToString());
            }
            catch (InvalidOperationException ioex)
            {
                Console.WriteLine("Delete Group failed due to exception: {0}", ioex.ToString());
            }
            catch (OperationFailureException ofex)
            {
                Console.WriteLine("Delete Group failed due to exception: {0}", ofex.ToString());
            }
            catch (RealTimeException rtex)
            {
                Console.WriteLine("Delete Group failed due to exception: {0}", rtex.ToString());
            }
            finally
            {
                // Unsubscribe to target user
                _remotePresenceView.StartUnsubscribingToPresentities(new string[] { _target.Address.Uri });
            }
        }
Beispiel #9
0
        // Callback triggered when group is added
        private void EndAddGroupCompleted(IAsyncResult ar)
        {
            ContactGroupServices services = ar.AsyncState as ContactGroupServices;

            try
            {
                services.EndAddGroup(ar);
                Console.WriteLine("Group with name {0} was created.", _groupName);
            }
            catch (PublishSubscribeException psex)
            {
                if (psex.DiagnosticInformation.Reason.Contains("Duplicate group name"))
                {
                    Console.WriteLine("Group {0} was not added because it already exists.", _groupName);
                }
                else
                {
                    Console.WriteLine("Add Group failed due to exception: {0}", psex.ToString());
                }
            }
            catch (InvalidOperationException ioex)
            {
                Console.WriteLine("Add Group failed due to exception: {0}", ioex.ToString());
            }
            catch (OperationFailureException ofex)
            {
                Console.WriteLine("Add Group failed due to exception: {0}", ofex.ToString());
            }
            catch (RealTimeException rtex)
            {
                Console.WriteLine("Add Group failed due to exception: {0}", rtex.ToString());
            }
        }
Beispiel #10
0
 public static Task AddGroupAsync(this
                                  ContactGroupServices cgs, string groupName,
                                  string groupData)
 {
     return(Task.Factory.FromAsync(
                cgs.BeginAddGroup, cgs.EndAddGroup,
                groupName, groupData, null));
 }
Beispiel #11
0
        // Callback triggered when subscription to ContactGroupServices
        // completes
        private void EndSubscribeCompleted(IAsyncResult ar)
        {
            ContactGroupServices services = ar.AsyncState as ContactGroupServices;

            try
            {
                services.EndSubscribe(ar);
                _waitForSubscribedToContactsGroupsCompleted.Set();
            }
            catch (RealTimeException exception)
            {
                Console.WriteLine("Contact Group Subscription failed due to exception: {0}",
                                  exception.ToString());
            }
        }
        // Callback method referred to in the call to BeginUnsubscribe on the ContactGroupServices instance.
        private void ContactGroupUnsubscribeCB(IAsyncResult ar)
        {
            ContactGroupServices services = ar.AsyncState as ContactGroupServices;

            try
            {
                services.EndUnsubscribe(ar);
            }

            // A production application should have catch blocks for a number
            // of other exceptions, including InvalidOperationException and PublishSubscribeException.
            catch (RealTimeException exception)
            {
                Console.WriteLine("Contact Group Unsubscription failed due to exception: {0}",
                                  exception.ToString());
            }
        }
Beispiel #13
0
        private void StartupUserEndpoint(AsyncTask task, object state)
        {
            AsyncTask proxyTask = new AsyncTask(m_customerSession.AppFrontEnd.CreateOrGetUserEndpoint, m_customerSession.Customer.UserUri);

            proxyTask.TaskCompleted +=
                delegate(object sender, AsyncTaskCompletedEventArgs e)
            {
                UserEndpointCreationActionResult result = proxyTask.TaskResult as UserEndpointCreationActionResult;
                if (result != null)
                {
                    m_myUserEndpoint       = result.MyUserEndpoint;
                    m_contactGroupServices = m_myUserEndpoint.UserEndpoint.ContactGroupServices;
                }
                task.Complete(e.ActionResult.Exception);
            };
            proxyTask.StartTask();
        }
Beispiel #14
0
 public static Task DeleteGroupAsync(this
                                     ContactGroupServices cgs, int groupId)
 {
     return(Task.Factory.FromAsync(
                cgs.BeginDeleteGroup, cgs.EndDeleteGroup, groupId, null));
 }