void On_InstantMessagingCall_Received_ByCallee(object sender, CallReceivedEventArgs <InstantMessagingCall> e) { //Type checking was done by the platform; no risk of this being any // type other than the type expected. InstantMessagingCall instantMessagingCall = e.Call; // Call: StateChanged: Only hooked up for logging, to show the call // state transitions. instantMessagingCall.StateChanged += new EventHandler <CallStateChangedEventArgs>(_call_StateChanged); // Remote Participant URI represents the far end (caller) in this // conversation. Toast is the message set by the caller as the 'greet' // message for this call. In Microsoft Lync, the toast will // show up in the lower-right of the screen. Conversation ID demonstrates // that the two calls inhabit the same conversation container on // both ends of the call. Console.WriteLine(""); Console.WriteLine(" Call Received! From: " + e.RemoteParticipant.Uri); Console.WriteLine(" Toast is: " + e.ToastMessage.Message); Console.WriteLine(" Conversation ID is: " + e.Call.Conversation.Id); Console.WriteLine(""); // Now, accept the call. // EndAcceptCall will be raised on the same thread. instantMessagingCall.BeginAccept(EndAcceptCall, instantMessagingCall); // When an escalation request is received on the existing call, this // event handler will be called. instantMessagingCall.Conversation.EscalateToConferenceRequested += this.CalleeConversation_EscalateToConferenceRequested; }
private void OnIncomingInstantMessagingCallReceived(object sender, CallReceivedEventArgs<InstantMessagingCall> e) { _imCall = e.Call; try { // Accept the incoming call. _imCall.BeginAccept(ar => { try { _imCall.EndAccept(ar); _logger.Log("Accepted incoming call."); } catch (RealTimeException rtex) { _logger.Log("Failed accepting incoming IM call.", rtex); } }, null); } catch (InvalidOperationException ioex) { _logger.Log("Failed accepting incoming IM call.", ioex); } }
public void InstantMessagingCall_Received(CallReceivedEventArgs <InstantMessagingCall> e) { if (_state == TranscriptRecorderState.Terminated) { NonBlockingConsole.WriteLine("Error: IMTranscriptRecorder is shutdown."); // TODO: Info message return; } if (_instantMessagingCall != null) { NonBlockingConsole.WriteLine("Warn: IMCall already exists for this Conversation. Shutting down previous call..."); // TODO: Info message TerminateCall(); } _state = TranscriptRecorderState.Initialized; _waitForIMCallTerminated.Reset(); // Type checking was done by the platform; no risk of this being any // type other than the type expected. _instantMessagingCall = e.Call; // Call: StateChanged: Only hooked up for logging, to show the call // state transitions. _instantMessagingCall.StateChanged += new EventHandler <CallStateChangedEventArgs>(InstantMessagingCall_StateChanged); _instantMessagingCall.InstantMessagingFlowConfigurationRequested += new EventHandler <InstantMessagingFlowConfigurationRequestedEventArgs>(InstantMessagingCall_FlowConfigurationRequested); _instantMessagingCall.ConversationChanged += new EventHandler <ConversationChangedEventArgs>(InstantMessagingCall_ConversationChanged); // Remote Participant URI represents the far end (caller) in this // conversation. Toast is the message set by the caller as the // 'greet' message for this call. In Microsoft Lync, the // toast will show up in the lower-right of the screen. // TODO: Change to protect privacy // NonBlockingConsole.WriteLine("IMCall Received! From: " + e.RemoteParticipant.Uri + " Toast is: " + e.ToastMessage.Message); NonBlockingConsole.WriteLine("IMCall Received! From: " + e.RemoteParticipant.Uri); // Console.Writelin("IMCall Received!"); Message m = new Message("InstantMessagingCall Received. Inbound call state: " + _instantMessagingCall.State.ToString(), e.RemoteParticipant.DisplayName, e.RemoteParticipant.UserAtHost, e.RemoteParticipant.Uri, MessageType.InstantMessage, _transcriptRecorder.Conversation.Id, MessageDirection.Incoming); _transcriptRecorder.OnMessageReceived(m); // Now, accept the call. EndAcceptCall will be raised on the // same thread. _instantMessagingCall.BeginAccept(InstantMessagingCallAcceptedCallBack, _instantMessagingCall); }
internal void HandleSupervisorInitialCall(InstantMessagingCall imCall) { Debug.Assert(imCall is InstantMessagingCall); _logger.Log("AcdSupervisorSession receives first incoming Call from " + imCall.RemoteEndpoint.Participant.Uri); if (_state == SupervisorSessionState.Incoming) { // sets the initial customer call _initialSupervisorCall = imCall; // monitors the customer-facing conversation state this.SetFrontEndConversationProperties(imCall); try { imCall.BeginAccept(ar => { try { imCall.EndAccept(ar); this.InitializeSupervisorControlChannel(); } catch (RealTimeException rtex) { _logger.Log("AcdSupervisorSession failed to end accept the incoming call from Supervisor", rtex); this.BeginShutDown(sdar => { this.EndShutDown(sdar); }, null); } }, null); } catch (InvalidOperationException ivoex) { _logger.Log("AcdSupervisorSession failed to accept the incoming call from Supervisor", ivoex); this.BeginShutDown(sdar => { this.EndShutDown(sdar); }, null); } } else { _logger.Log("AcdSupervisorSession is not in the correct state to process the new initial call"); this.BeginShutDown(ar => { this.EndShutDown(ar); }, null); } }
void InstantMessagingCall_Received(object sender, CallReceivedEventArgs <InstantMessagingCall> e) { // Type checking was done by the platform; no risk of this being any // type other than the type expected. _instantMessagingCall = e.Call; _incomingConversation = _instantMessagingCall.Conversation; // Call: StateChanged: Hooked up for logging, to show callstate transitions. _instantMessagingCall.StateChanged += new EventHandler <CallStateChangedEventArgs>(InstantMessagingCall_StateChanged); // RemoteParticipantUri is the URI of the remote caller in this // conversation. Toast is the message set by the caller as the // 'greet' message for this call. Console.WriteLine("Call Received! From: " + e.RemoteParticipant.Uri + " Toast is: " + e.ToastMessage.Message); // Accept the call. _instantMessagingCall.BeginAccept(CallAcceptCB, _instantMessagingCall); }
void On_InstantMessagingCall_Received(object sender, CallReceivedEventArgs <InstantMessagingCall> e) { // Type checking was done by the platform; no risk of this being any // type other than the type expected. _instantMessagingCall = e.Call; // Call: StateChanged: Only hooked up for logging, to show the call // state transitions. _instantMessagingCall.StateChanged += new EventHandler <CallStateChangedEventArgs>(InstantMessagingCall_StateChanged); // Remote Participant URI represents the far end (caller) in this // conversation. Toast is the message set by the caller as the // 'greet' message for this call. In Microsoft Lync, the // toast will show up in the lower-right of the screen. Console.WriteLine("Call Received! From: " + e.RemoteParticipant.Uri + " Toast is: " + e.ToastMessage.Message); // Now, accept the call. EndAcceptCall will be raised on the // same thread. _instantMessagingCall.BeginAccept(EndAcceptCall, _instantMessagingCall); }
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) { } }
/// <summary> /// Handle incoming IM call from the customer. /// </summary> /// <param name="imCall">IM call.</param> public void HandleIncomingInstantMessagingCall(InstantMessagingCall imCall) { lock (syncRoot) { if (this.conversation == null) { this.conversation = imCall.Conversation; this.RegisterConversationEventHandlers(this.conversation); } if (this.conversationContextChannel == null && !String.IsNullOrEmpty(this.application.CweGuid)) { this.conversationContextChannel = new ConversationContextChannel(this.conversation, imCall.RemoteEndpoint); this.RegisterContextChannelHandlers(this.conversationContextChannel); } this.imIvr = new InstantMessagingIVR(this, imCall, this.conversationContextChannel, this.menu, this.logger); this.imIvr.isUserEndpointFirstMessage = true; try { imCall.BeginAccept((asyncResult) => { try { imCall.EndAccept(asyncResult); if (this.conversationContextChannel != null && this.conversationContextChannel.State == ConversationContextChannelState.Idle) { ConversationContextChannelEstablishOptions channelOptions = new ConversationContextChannelEstablishOptions(); channelOptions.ApplicationName = this.application.Name; channelOptions.ContextualData = "Context channel is open."; channelOptions.Toast = "Please check the accompaining CWE window for Graphical Experience"; Guid appGuid = new Guid(this.application.CweGuid); try { this.conversationContextChannel.BeginEstablish(appGuid, channelOptions, (contextChannelAsyncResult) => { try { this.conversationContextChannel.EndEstablish(contextChannelAsyncResult); } catch (RealTimeException rte) { Console.WriteLine("Error establishing conversation context channel {0}", rte); this.logger.Log("Error establishing conversation context channel {0}", rte); } }, null); } catch (InvalidOperationException ioe) { Console.WriteLine("Error establishing conversation context channel {0}", ioe); this.logger.Log("Error establishing conversation context channel {0}", ioe); } } } catch (RealTimeException rte) { Console.WriteLine("Error accepting incoming IM call {0}", rte); this.logger.Log("Error accepting incoming IM call {0}", rte); } }, null); } catch (InvalidOperationException ioe) { Console.WriteLine("Error accepting incoming IM call {0}", ioe); this.logger.Log("Error accepting incoming IM call {0}", ioe); } } }
public void InstantMessagingCall_Received(CallReceivedEventArgs<InstantMessagingCall> e) { if (_state == TranscriptRecorderState.Terminated) { NonBlockingConsole.WriteLine("Error: IMTranscriptRecorder is shutdown."); // TODO: Info message return; } if (_instantMessagingCall != null) { NonBlockingConsole.WriteLine("Warn: IMCall already exists for this Conversation. Shutting down previous call..."); // TODO: Info message TerminateCall(); } _state = TranscriptRecorderState.Initialized; _waitForIMCallTerminated.Reset(); // Type checking was done by the platform; no risk of this being any // type other than the type expected. _instantMessagingCall = e.Call; // Call: StateChanged: Only hooked up for logging, to show the call // state transitions. _instantMessagingCall.StateChanged += new EventHandler<CallStateChangedEventArgs>(InstantMessagingCall_StateChanged); _instantMessagingCall.InstantMessagingFlowConfigurationRequested += new EventHandler<InstantMessagingFlowConfigurationRequestedEventArgs>(InstantMessagingCall_FlowConfigurationRequested); _instantMessagingCall.ConversationChanged += new EventHandler<ConversationChangedEventArgs>(InstantMessagingCall_ConversationChanged); // Remote Participant URI represents the far end (caller) in this // conversation. Toast is the message set by the caller as the // 'greet' message for this call. In Microsoft Lync, the // toast will show up in the lower-right of the screen. // TODO: Change to protect privacy // NonBlockingConsole.WriteLine("IMCall Received! From: " + e.RemoteParticipant.Uri + " Toast is: " + e.ToastMessage.Message); NonBlockingConsole.WriteLine("IMCall Received! From: " + e.RemoteParticipant.Uri); // Console.Writelin("IMCall Received!"); Message m = new Message("InstantMessagingCall Received. Inbound call state: " + _instantMessagingCall.State.ToString(), e.RemoteParticipant.DisplayName, e.RemoteParticipant.UserAtHost, e.RemoteParticipant.Uri, MessageType.InstantMessage, _transcriptRecorder.Conversation.Id, MessageDirection.Incoming); _transcriptRecorder.OnMessageReceived(m); // Now, accept the call. EndAcceptCall will be raised on the // same thread. _instantMessagingCall.BeginAccept(InstantMessagingCallAcceptedCallBack, _instantMessagingCall); }