/// <summary> /// Im flow message received event handler. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ImFlowMessageReceived(object sender, InstantMessageReceivedEventArgs e) { if (Boolean.Parse(System.Configuration.ConfigurationManager.AppSettings["UseUserEndPoint"])) { if (this.isUserEndpointFirstMessage) { this.isUserEndpointFirstMessage = false; return; } } InstantMessagingFlow imFlow = sender as InstantMessagingFlow; string userResponse = e.TextBody.Trim(); Console.WriteLine("Received _ :" + userResponse + " from " + e.Sender.Uri); MimePartContentDescription package = this.menu.HandleUserInput(userResponse); if (package != null) { try { imFlow.BeginSendInstantMessage(package.ContentType, package.GetBody(), (asyncResult) => { try { imFlow.EndSendInstantMessage(asyncResult); } catch (RealTimeException rte) { Console.WriteLine("Exception while sending message {0}", rte); this.logger.Log("Exception while sending message {0}", rte); } }, null); } catch (InvalidOperationException ioe) { Console.WriteLine("Exception while sending message {0}", ioe); this.logger.Log("Exception while sending message {0}", ioe); } } }
/// <summary> /// Im flow state changed event handler. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ImFlowStateChanged(object sender, MediaFlowStateChangedEventArgs e) { if (e.State == MediaFlowState.Active) { InstantMessagingFlow imFlow = sender as InstantMessagingFlow; MimePartContentDescription package = null; // Get the top level menu. if (this.menu.Level == MenuLevel.None) { package = this.menu.HandleUserInput(" "); } else { package = this.menu.GetMessage(); } if (package != null) { this.SendStatusMessageToCustomer(package.ContentType, package.GetBody()); } } }