static public agentType Convert(Agent agent, ConversationParticipant participant) { agentType agentT = new agentType(); if (null != participant) { agentT.displayname = participant.DisplayName; agentT.uri = participant.Uri; int numberOfActiveModalities = participant.GetActiveMediaTypes().Count; if (numberOfActiveModalities != 0) { agentT.mediatypes = new string[numberOfActiveModalities]; int i = 0; foreach (String mediaType in participant.GetActiveMediaTypes()) { agentT.mediatypes[i++] = mediaType; } } } else { agentT.displayname = new SipUriParser(agent.SignInAddress).User; agentT.uri = agent.SignInAddress; } KeyValuePair <DateTime, bool> allocated = agent.GetWhetherAllocated(); agentT.status = allocated.Value ? "Active" : "Idle"; agentT.statuschangedtime = allocated.Key.Ticks.ToString(); return(agentT); }
private void ReceiveIncomingIMCall(object sender, CallReceivedEventArgs <InstantMessagingCall> e) { this.Logger.Log(Logger.LogLevel.Verbose, string.Format( CultureInfo.InvariantCulture, "IMCall {0} received.", Logger.Pointer(e.Call))); if (this.IsTerminatingTerminated || e.IsConferenceDialOut) { var declineOptions = new CallDeclineOptions(); declineOptions.ResponseCode = ResponseCode.RequestTerminated; this.RejectCall(e.Call, declineOptions); return; } ConversationParticipant caller = e.Call.RemoteEndpoint.Participant; RealTimeAddress uriAddress = new RealTimeAddress(caller.Uri); if (!uriAddress.IsPhone && e.Call.RemoteEndpoint.Participant.SourceNetwork == SourceNetwork.SameEnterprise) { System.Threading.ThreadPool.QueueUserWorkItem(this.HandleIMCall, e); } else { var declineOptions = new CallDeclineOptions(); declineOptions.ResponseCode = ResponseCode.RequestTerminated; this.RejectCall(e.Call, declineOptions); return; } }
//public static Task ModifyConferenceConfigurationAsync(this ConferenceSession session, // ConferenceAccessLevel accessLevel, LobbyBypass lobbyBypass, // AutomaticLeaderAssignment automaticLeaderAssignment, // ModifyConferenceConfigurationOptions options) //{ // return Task.Factory.FromAsync(session.BeginModifyConferenceConfiguration, // session.EndModifyConferenceConfiguration, accessLevel, lobbyBypass, // automaticLeaderAssignment, options, null); //} public static Task ModifyRole(this ConferenceSession session, ConversationParticipant participant, ConferencingRole role) { return Task.Factory.FromAsync(session.BeginModifyRole, session.EndModifyRole, participant, role, null); }
public ConversationParticipant GetParticipantInfo(int userId, int recepientId) { ConversationParticipant participant = new ConversationParticipant(); _dataProvider.ExecuteCmd( "dbo.UserConversations_SelectUserInfoAndRecentMessage_V2", (paramCol) => { paramCol.AddWithValue("@UserId", userId); paramCol.AddWithValue("@RecepientId", recepientId); }, (reader, recordSetIndex) => { int startingIndex = 0; participant.UserId = reader.GetSafeInt32(startingIndex++); participant.ParticipantId = reader.GetSafeInt32(startingIndex++); participant.CurrentId = reader.GetSafeInt32(startingIndex++); participant.ConversationId = reader.GetSafeInt32(startingIndex++); participant.FirstName = reader.GetSafeString(startingIndex++); participant.LastName = reader.GetSafeString(startingIndex++); participant.AvatarUrl = reader.GetSafeString(startingIndex++); participant.Body = reader.GetSafeString(startingIndex++); participant.DateCreated = reader.GetSafeDateTime(startingIndex++); } ); return(participant); }
public async Task CreateConversationParticipant(ConversationParticipant participant) { await _dbConnection.ExecuteAsync( @"INSERT INTO [ConversationParticipants] ([ConversationId], [UserId], [CreatedAt]) VALUES (@ConversationId, @UserId, @CreatedAt)", new { ConversationId = participant.ConversationId, UserId = participant.UserId, CreatedAt = participant.CreatedAt } ); }
/// <summary> /// To create a new customer call anchor. /// </summary> /// <param name="customerSession">Customer session.</param> /// <param name="customerConversation">Customer conversation.</param> public CustomerCallAnchor(CustomerSession customerSession, ILogger logger, Conversation customerConversation) { this.customerConversation = customerConversation; this.customerRemoteParticipant = customerConversation.RemoteParticipants[0]; this.customerSession = customerSession; this.logger = logger; }
public static Task ModifyRole(this ConferenceSession session, ConversationParticipant participant, ConferencingRole role, ModifyRoleOptions options) { return(Task.Factory.FromAsync(session.BeginModifyRole, session.EndModifyRole, participant, role, options, null)); }
void SpeechRecognitionEngine_LoadGrammarCompleted(object sender, LoadGrammarCompletedEventArgs e) { if (e.Error != null) { NonBlockingConsole.WriteLine("Error: SpeechRecognizer receieved error from LoadGrammar(): " + e.ToString()); string errorMessageText = "Error: SpeechRecognizer receieved error from LoadGrammar(): " + e.ToString(); Conversation conv = _audioVideoFlow.Call.Conversation; ConversationParticipant speaker = _audioVideoFlow.Call.RemoteEndpoint.Participant; Message m = new Message(errorMessageText, speaker.DisplayName, speaker.UserAtHost, speaker.Uri, DateTime.Now, conv.Id, conv.ConferenceSession.ConferenceUri, MessageType.Error, MessageDirection.Outgoing); this._transcriptRecorder.OnMessageReceived(m); _transcriptRecorder.OnMediaTranscriptRecorderError(m); } _pendingLoadSpeechGrammarCounter--; NonBlockingConsole.WriteLine("SpeechRecognitionEngine load grammar completed. Pending grammar loads remaining: " + _pendingLoadSpeechGrammarCounter.ToString()); if (_pendingLoadSpeechGrammarCounter == 0) { _waitForLoadGrammarCompleted.Set(); } }
// Callback that handles when the state of an AudioVideoFlow changes private void AudioVideoFlow_StateChanged(object sender, MediaFlowStateChangedEventArgs e) { NonBlockingConsole.WriteLine("AV flow state changed from " + e.PreviousState + " to " + e.State); string messageText = ""; //When flow is active, media operations can begin if (e.State == MediaFlowState.Active) { NonBlockingConsole.WriteLine("Starting speech recognition"); messageText = "Starting speech recognition"; // Flow-related media operations normally begin here. _waitForAudioVideoFlowStateChangedToActiveCompleted.Set(); StartSpeechRecognition(); } else if (e.State == MediaFlowState.Terminated) { NonBlockingConsole.WriteLine("Stopping speech recognition"); messageText = "Stopping speech recognition"; // Detach SpeechSynthesisConnector since AVFlow will not work anymore this.StopSpeechRecognition(); } if (!String.IsNullOrEmpty(messageText) && (this._transcriptRecorder != null)) { Conversation conv = _audioVideoFlow.Call.Conversation; ConversationParticipant speaker = _audioVideoFlow.Call.RemoteEndpoint.Participant; Message m = new Message(messageText, speaker.DisplayName, speaker.UserAtHost, speaker.Uri, DateTime.Now, conv.Id, conv.ConferenceSession.ConferenceUri, MessageType.Info, MessageDirection.Outgoing); this._transcriptRecorder.OnMessageReceived(m); } }
public void Join(Client client) { _participants.Add(client); using (var database = new RozmawiatorDb()) { var user = database.Users.Select(u => new { u.Id, u.UserName }) .FirstOrDefault(u => u.UserName == client.Nickname); if (user != null) { var conversation = database.Conversations.First(c => c.Id == _conversationId); var participant = conversation.ConversationParticipants.FirstOrDefault(p => p.UserId == user.Id); if (participant != null) { participant.IsActive = true; } else { participant = new ConversationParticipant { Conversation = conversation, UserId = user.Id }; conversation.ConversationParticipants.Add(participant); } } database.SaveChanges(); } Broadcast(new Message(client.Id, 0, Message.MessageType.HelloConversation, client.Nickname)); ParticipantsUpdate?.Invoke(this); }
private ConversationParticipant ConversationThreadMapper(IDataReader reader) { ConversationParticipant threads = new ConversationParticipant(); int index = 0; threads.ParticipantId = reader.GetSafeInt32(index++); threads.ConversationId = reader.GetSafeInt32(index++); threads.FirstName = reader.GetSafeString(index++); threads.LastName = reader.GetSafeString(index++); threads.AvatarUrl = reader.GetSafeString(index++); return(threads); }
void SpeechRecognitionEngine_SpeechDetected(object sender, Microsoft.Speech.Recognition.SpeechDetectedEventArgs e) { NonBlockingConsole.WriteLine("SpeechRecognitionEngine has detected speech."); Conversation conv = _audioVideoFlow.Call.Conversation; ConversationParticipant speaker = _audioVideoFlow.Call.RemoteEndpoint.Participant; Message m = new Message("SpeechRecognitionEngine has detected speech.", speaker.DisplayName, speaker.UserAtHost, speaker.Uri, DateTime.Now, conv.Id, (conv.ConferenceSession == null)? "null" : conv.ConferenceSession.ConferenceUri, MessageType.Audio, MessageDirection.Outgoing); this._transcriptRecorder.OnMessageReceived(m); }
public TranscriptRecorderSession(ConferenceInvitationReceivedEventArgs e, CancellationTokenSource cts = null) { _sessionId = Constants.NextGuid(); _transcriptRecorders = new List <MediaTranscriptRecorder>(); _conversationToCallTranscriptMapping = new Dictionary <ConversationTranscriptRecorder, List <MediaTranscriptRecorder> >(); _messages = new List <Message>(); _state = TranscriptRecorderState.Active; ConversationParticipant caller = e.RemoteParticipant; // Log Conference Invitation Recv Message m = new Message("Conference Started Invitation Recieved for ConferenceUri: ", caller.DisplayName, caller.UserAtHost, caller.Uri, DateTime.Now, "null", e.Invitation.ConferenceUri, MessageType.ConferenceInfo, MessageDirection.Outgoing); this.OnMessageReceived(m); AddIncomingInvitedConference(e); }
public void AddIncomingInvitedConference(ConferenceInvitationReceivedEventArgs e, CancellationTokenSource cts = null) { if (_state != TranscriptRecorderState.Active) { NonBlockingConsole.WriteLine("Warn: AddIncomingInvitedConferece in unexpected TranscriptRecorderSession state: " + _state.ToString()); } // Log Conference Invitation Recv ConversationParticipant caller = e.RemoteParticipant; Message m = new Message("Conference Started Invite Accept Started.", caller.DisplayName, caller.UserAtHost, caller.Uri, DateTime.Now, "null", e.Invitation.ConferenceUri, MessageType.ConferenceInfo, MessageDirection.Outgoing); this.OnMessageReceived(m); e.Invitation.BeginAccept(ConferenceInvitation_AcceptCompleted, e.Invitation); }
void SpeechRecognitionEngine_RecognizeCompleted(object sender, Microsoft.Speech.Recognition.RecognizeCompletedEventArgs e) { NonBlockingConsole.WriteLine("SpeechRecognitionEngine_RecognizeCompleted."); string messageText = ""; MessageType messageModality = MessageType.Audio; Microsoft.Speech.Recognition.RecognitionResult result = e.Result; if (result != null) { NonBlockingConsole.WriteLine("Speech recognized: " + result.Text); _speechTranscript.Add(result); messageText = result.Text; } else if (e.Error != null) { messageText = e.Error.ToString(); messageModality = MessageType.Error; NonBlockingConsole.WriteLine("Error occured during speech detection: " + e.Error.ToString()); } else if (e.InputStreamEnded || e.Cancelled) { NonBlockingConsole.WriteLine("Speech recognization completed due to user disconnect or conference ending."); messageText = "Speech recognization completed due to user disconnect or conference ending."; messageModality = MessageType.Info; } else { messageText = "Failed to recognize speech."; messageModality = MessageType.Error; NonBlockingConsole.WriteLine("Failed to recognize speech."); } if (!String.IsNullOrEmpty(messageText)) { Conversation conv = _audioVideoFlow.Call.Conversation; ConversationParticipant speaker = _audioVideoFlow.Call.RemoteEndpoint.Participant; Message m = new Message(messageText, speaker.DisplayName, speaker.UserAtHost, speaker.Uri, DateTime.Now, conv.Id, (conv.ConferenceSession == null) ? "null" : conv.ConferenceSession.ConferenceUri, messageModality, MessageDirection.Outgoing); this._transcriptRecorder.OnMessageReceived(m); } }
public List <ConversationParticipant> GetUserProfileConversation(int userId) { List <ConversationParticipant> participants = null; _dataProvider.ExecuteCmd( "dbo.UserConversations_SelectUserInfoAndRecentMessage", (paramCol) => { paramCol.AddWithValue("@UserId", userId); }, (reader, set) => { int startingIndex = 0; ConversationParticipant participant = new ConversationParticipant(); participant.UserId = reader.GetSafeInt32(startingIndex++); participant.ParticipantId = reader.GetSafeInt32(startingIndex++); participant.CurrentId = reader.GetSafeInt32(startingIndex++); participant.ConversationId = reader.GetSafeInt32(startingIndex++); participant.FirstName = reader.GetSafeString(startingIndex++); participant.LastName = reader.GetSafeString(startingIndex++); participant.AvatarUrl = reader.GetSafeString(startingIndex++); participant.Body = reader.GetSafeString(startingIndex++); participant.TimeSent = reader.GetSafeDateTime(startingIndex++); if (participants == null) { participants = new List <ConversationParticipant>(); } participants.Add(participant); } ); return(participants); }
public List <ConversationParticipant> GetConversationThreads(int userId) { List <ConversationParticipant> threads = null; _dataProvider.ExecuteCmd("dbo.UserConversations_SelectConversationsByUserId_V2", (parameters) => { parameters.AddWithValue("@UserId", userId); }, (reader, shortSetIndex) => { ConversationParticipant thread = ConversationThreadMapper(reader); if (threads == null) { threads = new List <ConversationParticipant>(); } threads.Add(thread); }); return(threads); }
/// <summary> /// Retrieves the properties for the specified Conversation Participant. /// </summary> /// <param name="currentParticipant">The participant who's properties /// are to be retrieved.</param> /// <returns>A string of the retrieved properties.</returns> private string RetrieveParticipantProperties(ConversationParticipant currentParticipant) { StringBuilder participantPropertiesSB = new StringBuilder(); participantPropertiesSB.AppendLine("Properties for the participant with Uri = " + currentParticipant.Uri); if (0 < currentParticipant.GetActiveMediaTypes().Count) { participantPropertiesSB.Append("\tActiveMediaTypes = "); Collection <string> activeMediaTypes = currentParticipant.GetActiveMediaTypes(); foreach (var activeMediaType in activeMediaTypes) { participantPropertiesSB.Append(string.Format("'{0}' ", activeMediaType)); } participantPropertiesSB.AppendLine(); } if (!string.IsNullOrEmpty(currentParticipant.DisplayName)) { participantPropertiesSB.AppendLine("\t DisplayName = " + currentParticipant.DisplayName); } if (!string.IsNullOrEmpty(currentParticipant.OtherPhoneUri)) { participantPropertiesSB.AppendLine("\t OtherPhoneUri = " + currentParticipant.OtherPhoneUri); } if (!string.IsNullOrEmpty(currentParticipant.PhoneUri)) { participantPropertiesSB.AppendLine("\t PhoneUri = " + currentParticipant.PhoneUri); } participantPropertiesSB.AppendLine("\t Role = " + currentParticipant.Role); participantPropertiesSB.AppendLine("\t RosterVisibility = " + currentParticipant.RosterVisibility); if (!string.IsNullOrEmpty(currentParticipant.UserAtHost)) { participantPropertiesSB.AppendLine("\t UserAtHost = " + currentParticipant.UserAtHost); } return(participantPropertiesSB.ToString()); }
public void AddIMIncomingCall(CallReceivedEventArgs <InstantMessagingCall> e, CancellationTokenSource cts = null) { if (_state != TranscriptRecorderState.Active) { NonBlockingConsole.WriteLine("Warn: AddIMIncomingCall in unexpected TranscriptRecorderSession state: " + _state.ToString()); } IMTranscriptRecorder i = new IMTranscriptRecorder(this); ConversationParticipant caller = e.RemoteParticipant; Message m = new Message("InstantMessaging Conversation Participant Added.", caller.DisplayName, caller.UserAtHost, caller.Uri, DateTime.Now, _conversation.Id, _conversation.ConferenceSession.ConferenceUri, MessageType.ConversationInfo, MessageDirection.Outgoing); this.OnMessageReceived(m); _transcriptRecorders.Add(i); _conversationToCallTranscriptMapping[_conversationTranscriptRecorder].Add(i); i.InstantMessagingCall_Received(e); }
public TranscriptRecorderSession(CallReceivedEventArgs <InstantMessagingCall> e, CancellationTokenSource cts = null) { _sessionId = Constants.NextGuid(); _transcriptRecorders = new List <MediaTranscriptRecorder>(); _conversationToCallTranscriptMapping = new Dictionary <ConversationTranscriptRecorder, List <MediaTranscriptRecorder> >(); _messages = new List <Message>(); _state = TranscriptRecorderState.Active; _conversation = e.Call.Conversation; _conversationTranscriptRecorder = new ConversationTranscriptRecorder(this, _conversation); _transcriptRecorders.Add(_conversationTranscriptRecorder); _conversationToCallTranscriptMapping.Add(_conversationTranscriptRecorder, new List <MediaTranscriptRecorder>()); ConversationParticipant caller = e.RemoteParticipant; // Log IM conversation started Message m = new Message("InstantMessaging Conversation/Conference Started.", caller.DisplayName, caller.UserAtHost, caller.Uri, DateTime.Now, _conversation.Id, (_conversation.ConferenceSession == null) ? "null" : _conversation.ConferenceSession.ConferenceUri, MessageType.ConferenceInfo, MessageDirection.Outgoing); this.OnMessageReceived(m); AddIMIncomingCall(e); }
private static void AddTestData(AppDbContext context) { Conversation firstConversation = new Conversation() { Subject = "First", IsComplete = false }; Conversation secondConversation = new Conversation() { Subject = "Second", IsComplete = true }; Participant piet = new Participant() { Name = "Piet", IsPatient = true }; Participant doc = new Participant() { Name = "Doc", IsPatient = false }; ConversationParticipant docPietConversation = new ConversationParticipant() { ConversationId = firstConversation.Id, Conversation = firstConversation, ParticipantId = piet.Id, Participant = piet }; ConversationParticipant pietDocConversation = new ConversationParticipant() { ConversationId = firstConversation.Id, Conversation = firstConversation, ParticipantId = doc.Id, Participant = doc }; Message hiMessage = new Message() { _Message = "Hello world", ConversationId = firstConversation.Id, Conversation = firstConversation, Participant = piet, ParticipantId = piet.Id, SentDateTime = new DateTime(2018, 9, 11, 19, 44, 21) }; firstConversation.Messages = new List <Message>() { { hiMessage } }; context.Conversations.Add(firstConversation); context.Conversations.Add(secondConversation); context.Messages.Add(hiMessage); context.Participants.Add(piet); context.Participants.Add(doc); context.ConversationParticipants.Add(docPietConversation); context.ConversationParticipants.Add(pietDocConversation); context.SaveChanges(); }
public static Task EjectAsync(this ConferenceSession session, ConversationParticipant participant) { return(Task.Factory.FromAsync(session.BeginEject, session.EndEject, participant, null)); }
private void Run() { // A helper class to take care of platform and endpoint setup and // cleanup. This has been abstracted from this sample to focus on // Call Control. _helper = new UCMASampleHelper(); // Create a user endpoint, using the network credential object // defined above. UserEndpoint callerEndpoint = _helper.CreateEstablishedUserEndpoint("Caller" /*endpointFriendlyName*/); // Create a second user endpoint, using the network credential object // defined above. UserEndpoint calleeEndpoint = _helper.CreateEstablishedUserEndpoint("Callee" /*endpointFriendlyName*/); // Here, we are accepting an InstantMessaging call only. // If the incoming call is not an InstantMessaging call (for example, // an AudioVideo call) then it will not get raised to the application. // UCMA 3.0 handles this silently by having the call types register // for various modalities (as part of the extensibility framework). // The appropriate action (here, accepting the call) will be handled // in the handler assigned to the method call below. calleeEndpoint.RegisterForIncomingCall <InstantMessagingCall> (On_InstantMessagingCall_Received_ByCallee); // Setup the call and conversation objects for the initial call (IM) // and place the call (synchronously). Conversation callerConversation = new Conversation(callerEndpoint); InstantMessagingCall callerInstantMessagingCall = new InstantMessagingCall(callerConversation); callerInstantMessagingCall.BeginEstablish(calleeEndpoint.OwnerUri, null, EndCallerCallEstablish, callerInstantMessagingCall); // Force synchronization to ensure that the call is now complete. _waitForCallAcceptByCallee.WaitOne(); _waitForCallerCallEstablish.WaitOne(); // Now that the call is established, we can begin the escalation. // First, we bind the conference state changed event handler, largely // for logging reasons. callerConversation.ConferenceSession.StateChanged += new EventHandler <StateChangedEventArgs <ConferenceSessionState> >(ConferenceSession_StateChanged); Console.WriteLine(""); Console.WriteLine(" Beginning conference creation and escalation..."); Console.WriteLine(""); // Next, the initiator of the escalation creates an ad-hoc conference // (using the current modalities present in the conversation) by calling // ConferenceSession.BeginJoin on a conversation, without providing // a conference URI. This prepares the calls for actual escalation by // binding the appropriate conference multipoint Control Unit (MCU) // sessions. When EndJoinConference is called, it will kick off the // subsequent escalation. As part of the escalation, the remote party // will receive an escalation request, via the event on the far end // conversation, EscalateToConferenceRequested. Also, the existing // calls will be shifted to the MCUs. callerConversation.ConferenceSession.BeginJoin(default(ConferenceJoinOptions), EndCallerJoinConference, callerConversation.ConferenceSession); //Wait for both sides to fully escalate to the new conference. _waitForCallerConferenceEscalation.WaitOne(); _waitForCalleeConferenceEscalation.WaitOne(); Console.WriteLine(""); Console.WriteLine(" Beginning conference command and control..."); Console.WriteLine(""); // Promote a participant to leader; Leaders can lock and unlock the // conference, as well as possessing the ability to eject and control // other participants, and mute participants (in an Audio conference). // For purposes of the demonstration, choose an arbitrary conference // participant here, the first. ConversationParticipant target = null; if (callerConversation.RemoteParticipants.Count >= 1) { target = callerConversation.RemoteParticipants[0]; } else { // TODO (Left to the reader): Add error handling code. } Console.WriteLine("User " + target.UserAtHost + " is currently an " + target.Role + "."); // Note: This is the naive synch implementation, and is not generally // suitable for production code. It is only used here for brevity. callerConversation.ConferenceSession.BeginModifyRole(target, ConferencingRole.Leader, EndModifyRole, callerConversation.ConferenceSession); _waitForRoleModification.WaitOne(); Console.WriteLine("User " + target.UserAtHost + " is now a " + target.Role + "."); Console.WriteLine("The conference access level is currently " + callerConversation.ConferenceSession.AccessLevel + "."); // Locking the conference prevents new users from joining the // conference, unless explicitly called into the conference through // the dialout API. callerConversation.ConferenceSession.BeginLockConference(EndLockConference, callerConversation.ConferenceSession); _waitForConferenceLock.WaitOne(); Console.WriteLine("The conference accesslevel is now " + callerConversation.ConferenceSession.AccessLevel + "."); // Now, eject the participant, and then shut down the platform. Console.WriteLine("The conference currently has " + callerConversation.ConferenceSession.GetRemoteParticipantEndpoints().Count + " attendees."); // Ejection can only be performed by leaders of the conference. callerConversation.ConferenceSession.BeginEject(target, EndEject, callerConversation.ConferenceSession); _waitForParticipantEject.WaitOne(); Console.WriteLine("The conference now has " + callerConversation.ConferenceSession.GetRemoteParticipantEndpoints().Count + " attendees."); _helper.ShutdownPlatform(); Console.ReadLine(); }
public static Task EjectAsync(this ConferenceSession session, ConversationParticipant participant) { return Task.Factory.FromAsync(session.BeginEject, session.EndEject, participant, null); }
private void HandleIMCall(object state) { CallReceivedEventArgs <InstantMessagingCall> e = state as CallReceivedEventArgs <InstantMessagingCall>; ConversationParticipant caller = e.Call.RemoteEndpoint.Participant; InstantMessagingCall imCall = e.Call; InstantMessagingFlow imFlow = null; int messageCount = 0; imCall.InstantMessagingFlowConfigurationRequested += delegate(object sender2, InstantMessagingFlowConfigurationRequestedEventArgs e2) { imFlow = e2.Flow; imFlow.MessageReceived += delegate(object sender3, InstantMessageReceivedEventArgs e3) { messageCount++; string message = e3.TextBody; message = message.Trim(); if (!String.IsNullOrEmpty(message) && message.StartsWith("add", StringComparison.OrdinalIgnoreCase)) { string[] tokens = message.Split(' '); if (this.AppPlatform.ReverseNumberLookUp.AddEntry(tokens[1], caller.Uri)) { this.SendIMResponse(imFlow, "Added telephone number."); } else { this.SendIMResponse(imFlow, "Telephone number exists."); } } else if (!String.IsNullOrEmpty(message) && message.StartsWith("remove", StringComparison.OrdinalIgnoreCase)) { string[] tokens = message.Split(' '); if (this.AppPlatform.ReverseNumberLookUp.RemoveEntry(tokens[1], caller.Uri)) { this.SendIMResponse(imFlow, "Removed telephone number."); } else { this.SendIMResponse(imFlow, "Telephone number does not exist or you do not own the tel #."); } } else if (!String.IsNullOrEmpty(message) && message.Equals("list", StringComparison.OrdinalIgnoreCase)) { Collection <string> list = this.AppPlatform.ReverseNumberLookUp.FindPhoneNumbers(caller.Uri); StringBuilder response = new StringBuilder(); foreach (string s in list) { response.Append(s); response.Append("\r\n"); } this.SendIMResponse(imFlow, response.ToString()); } else { this.SendIMHelpMessage(imFlow); } if (messageCount > 5) // We could also terminate based on timer. { this.TerminateIMCall(imCall); } }; }; try { imCall.BeginAccept( delegate(IAsyncResult ar) { try { imCall.EndAccept(ar); this.SendIMHelpMessage(imFlow); } catch (RealTimeException) { } }, null); } catch (InvalidOperationException) { } }