async Task <string> GetParticipantName(UcwaResourceParticipant p) { if (p != null) { return(await GetContactName(p.contactResourceUri)); } return(null); }
async void ProcessCommunicationEvents(IEnumerable <UcwaEvent> events) { foreach (var e in events) { ShowProcessProgress(string.Format(eventMessageFormat, e.Name, e.Type, e.Sender)); switch (e.Name) { case "communication": this.Resource = new UcwaResourceCommunication(e.Resource); ShowProcessProgress("\tResource: " + this.Resource.Name + "\r\n\tState =" + this.Resource.State + "\r\n\t" + this.Resource.ThreadId); break; case "messagingInvitation": this.messagingInvite = new UcwaResourceMessageInvitation(e); NotifyResourceStateChange(messagingInvite.State.ToLower(), messagingInvite.Name); //ShowProcessProgress("\tResource: " + this.messagingInvite.Name + "\r\n\tState: " + this.messagingInvite.State // + "\r\n\tDirection: " + messagingInvite.Direction + "\r\n\tThreadId: " + messagingInvite.ThreadId // + "\r\n\tmessagingUri:" + messagingInvite.messagingUri + "\r\n\tOperationId:" + messagingInvite.OperationId // + "\r\n\ttoUri:" + messagingInvite.toUri + "\r\n\tfromUri: " + messagingInvite.fromUri // + "\r\n\tStatus: " + messagingInvite.Status + "" // ); if (messagingInvite.Direction.ToLower() == "incoming") { // Must cache the following Uris, otherwise, they may not be available on later messagingInvitation events if (messagingInvite.acceptUri != null) { messagingInviteAcceptUri = messagingInvite.acceptUri; } if (messagingInvite.declineUri != null) { messagingInviteDeclineUri = messagingInvite.declineUri; } if (messagingInvite.ThreadId != null) { threadId = messagingInvite.ThreadId; } if (messagingInvite.ContainsResource("from")) { var from = new UcwaResourceParticipant( await messagingInvite.GetContainedResource("from", ucwaApp.Transport)); NotifyMessagingInvite(this.messagingInvite.Subject, this.messagingInvite.Importance, from.DisplayName, this.messagingInvite.Message, this.messagingInvite.ThreadId); } else { ShowProcessProgress("WARN: messagingInvite does not specify valid 'from' resource"); } } break; case "conversation": if (e.Type.ToLower() == "deleted") { NotifyResourceStateChange("deleted", e.Name); } else if (e.Resource != null) { var conv = new UcwaResourceConversation(e.Resource); { this.conversation = conv; NotifyResourceStateChange(conversation.State.ToLower(), conversation.Name); } ShowProcessProgress("\tThreadId: " + conv.ThreadId + "\r\n\tUri: " + conv.Uri + "" + conv.State + "\r\n\tParticipanCount: " + conv.ParticipantCount + "\r\n\tmessagingUri: " + conv.messagingUri); } else { this.ShowProcessProgress("WARN: conversation added event does not contain the corresponding resource."); } break; default: break; } } }