private void PresenceView_NotificationReceived(object sender, RemotePresentitiesNotificationEventArgs e) { var presenceView = (RemotePresenceView)sender; var request = (CallbackRequest)presenceView.ApplicationContext; foreach (var notification in e.Notifications) { Debug.Assert(notification.PresentityUri.Equals(request.TargetUri, StringComparison.OrdinalIgnoreCase)); if (notification.AggregatedPresenceState != null) { PresenceState state = notification.AggregatedPresenceState; var availability = state.Availability; if (availability == PresenceAvailability.Online || availability == PresenceAvailability.IdleOnline) { string logmessage = string.Format(CultureInfo.InvariantCulture, "{0} became online", request.TargetUri); this.Logger.Log(Logger.LogLevel.Verbose, logmessage); this.InitiateCallback(request); } break; } } }
private void PresenceReceivedEventHandler(object sender, RemotePresentitiesNotificationEventArgs e) { Console.WriteLine("PresenceReceivedEventHandler"); IEnumerable<RemotePresentityNotification> notifications = e.Notifications; // Make sure the call has finished // // Grap the first notification in the results RemotePresentityNotification notification = notifications.FirstOrDefault(); Console.WriteLine("Availability: " + notification.AggregatedPresenceState.Availability.ToString()); }
// Event handler to process remote target's presence notifications private void RemotePresence_PresenceNotificationReceived(object sender, RemotePresentitiesNotificationEventArgs e) { // Notifications contain all the notifications for one user. foreach (RemotePresentityNotification notification in e.Notifications) { Console.WriteLine(String.Format("Presence notifications received from {0}", notification.PresentityUri)); if (notification.AggregatedPresenceState != null) { Console.WriteLine("Aggregate State = " + notification.AggregatedPresenceState.Availability); } } }
// Handler for the PresenceNotificationReceived event. private void RemotePresenceView_PresenceNotificationReceived(object sender, RemotePresentitiesNotificationEventArgs e) { // The Notifications property contains all notifications for one user. foreach (RemotePresentityNotification notification in e.Notifications) { if (notification.AggregatedPresenceState != null && (notification.AggregatedPresenceState.Availability == PresenceAvailability.Online)) { _remoteContactUri = new Uri(notification.PresentityUri); Console.WriteLine("Remote target URI: " + _remoteContactUri.ToString()); // Can break out of loop after an available contact is found. break; } } _waitForAvailableTarget.Set(); }
/// <summary> /// Presence notification received. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">Event args.</param> private void RemotePresenceView_PresenceNotificationReceived(object sender, RemotePresentitiesNotificationEventArgs e) { List <PresenceInformation> presenceSubscriptions = new List <PresenceInformation>(); foreach (var notification in e.Notifications) { presenceSubscriptions.Add(ConvertNotificationToPresence(notification)); } var presenceChanged = this.PresenceChanged; if (presenceChanged != null) { presenceChanged(this, new PresenceChangedEventArgs { PresenceSubscriptions = presenceSubscriptions }); } }
// Event handler to process remote target's presence notifications private void RemotePresence_PresenceNotificationReceived(object sender, RemotePresentitiesNotificationEventArgs e) { Console.WriteLine(String.Format("Presence notifications received for target {0}", _remoteUserUri)); // Notifications contain all the notifications for one user. foreach (RemotePresentityNotification notification in e.Notifications) { if (notification.AggregatedPresenceState != null) { Console.WriteLine("Aggregate State = " + notification.AggregatedPresenceState.Availability); } } Console.WriteLine("Press ENTER to delete the contact, delete the group, and unsubscribe to the " + "presence of the remote user."); }
private void PresenceView_NotificationReceived( object sender, RemotePresentitiesNotificationEventArgs e) { lock (this.SyncRoot) { foreach (var notification in e.Notifications) { ContactInformation info = null; if (!m_contacts.TryGetValue(notification.PresentityUri, out info)) { continue; } foreach (var category in notification.Categories) { if (category.Name == PresenceCategoryNames.ContactCard) { var card = new ContactCard(category); info.AddContactCard(card); } else if (category.Name == PresenceCategoryNames.State) { string rawXml = category.Category.GetCategoryDataXml(); if (string.IsNullOrEmpty(rawXml)) { continue; } PresenceState state = new PresenceState(category); var availability = state.Availability; if (availability != PresenceAvailability.None) { info.Availability = availability; } } } } } }
/// <summary> /// Determines whether an agent has become available. /// </summary> private void HandleAgentAvailabilityChanged(object sender, RemotePresentitiesNotificationEventArgs e) { foreach (RemotePresentityNotification notification in e.Notifications) { Agent agent = this.LookupAgent(notification.PresentityUri); if (agent == null) { continue; } lock (agent) { agent.IsOnline = IsAgentAvailable(notification); } if (agent.IsOnline && !agent.IsAllocated) { this.HandleNewAvailableAgent(agent);; } } }
/// <summary> /// Log the presence notification for the remote user. /// </summary> /// <param name="sender">View that received the notification.</param> /// <param name="e">Data about the notifications received.</param> 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 + "."); } } }
void PollingPresenceReceivedEventHandler(object sender, RemotePresentitiesNotificationEventArgs e) { if (OnPollingPresenceReceived != null) RaiseEvent(OnPollingPresenceReceived, this, e); }
void QueryingPresenceReceivedEventHandler(object sender, RemotePresentitiesNotificationEventArgs e) { Console.WriteLine("An event received for QueryingPresenceReceivedEventHandler"); if (OnQueryingPresenceReceived != null) { foreach (RemotePresentityNotification presentity in e.Notifications) { Console.WriteLine("Availability: " + presentity); } RaiseEvent(OnQueryingPresenceReceived, this, e); } }
/// <summary> /// Invoked when the presence view is notified of new data. /// </summary> /// <param name="sender"></param> /// <param name="args"></param> void view_PresenceNotificationReceived(object sender, RemotePresentitiesNotificationEventArgs args) { // insert new data into cache lock (cache) foreach (var i in args.Notifications) cache[i.PresentityUri] = i.AggregatedPresenceState; // pulse anybody waiting cacheWh.Set(); }
private static void PresenceNotificationReceived(object sender, RemotePresentitiesNotificationEventArgs e) { ProcessPresenceNotification(e.Notifications); }