private void InstantMessagingFlow_MessageReceived(object sender, InstantMessageReceivedEventArgs e) { //xueming InstantMessagingFlow _instantMessagingFlow = sender as InstantMessagingFlow; // On an incoming Instant Message, print the contents to the console. Console.WriteLine(e.Sender.Uri + " said: " + e.TextBody); // Shutdown if the far end tells us to. if (e.TextBody.Equals("bye", StringComparison.OrdinalIgnoreCase)) { // Shutting down the platform will terminate all attached objects. // If this was a production application, it would tear down the // Call/Conversation, rather than terminating the entire platform. _instantMessagingFlow.BeginSendInstantMessage("Shutting Down...", SendMessageCompleted, _instantMessagingFlow); _helper.ShutdownPlatform(); _OCSCompletedEvent.Set(); } else { // Echo the instant message back to the far end (the sender of // the instant message). // Change the composing state of the local end user while sending messages to the far end. // A delay is introduced purposely to demonstrate the typing notification displayed by the // far end client; otherwise the notification will not last long enough to notice. _instantMessagingFlow.LocalComposingState = ComposingState.Composing; Thread.Sleep(2000); //Echo the message with an "Echo" prefix. _instantMessagingFlow.BeginSendInstantMessage("Echo: " + e.TextBody, SendMessageCompleted, _instantMessagingFlow); } }
// Delegate that is invoked when an incoming InstantMessageCall arrives. void IMFlow_MessageReceived(object sender, InstantMessageReceivedEventArgs e) { // If this is the first message, set _isFirstMessage to false and return. if (_isFirstMessage) { _isFirstMessage = false; Console.WriteLine("First message has arrived."); return; } // _isFirstMessage must be false, so look for a menu choice of 1 or 2. string choice = e.TextBody; Uri contact = null; if (choice.Equals("1")) { // Contact someone in the Service Dept. _groupID = GroupID.SERVICE_GROUP; } else if (choice.Equals("2")) { // Contact someone in the Sales Dept. _groupID = GroupID.SALES_GROUP; } contact = GetFirstAvailableContact(); }
private void instantMessagingFlow2_MessageReceived(object sender, InstantMessageReceivedEventArgs e) { InstantMessagingFlow instantMessagingFlow = sender as InstantMessagingFlow; //On an incoming Instant Message, print the contents to the console. Console.WriteLine("In callee's message handler: " + e.Sender.DisplayName + " said: " + e.TextBody); //Shutdown the platform if (e.TextBody.Equals("bye", StringComparison.OrdinalIgnoreCase)) { _helper.ShutdownPlatform(); _waitForShutdown.Set(); return; } Console.WriteLine("Message received will be echoed"); _messageToSend = "echo: " + e.TextBody; //Send the message on the InstantMessagingFlow. if (_IMFlow2 != null && _IMFlow2.State == MediaFlowState.Active) { _IMFlow2.BeginSendInstantMessage(_messageToSend, EndSendMessage, instantMessagingFlow); } else { Console.WriteLine("Could not echo message because flow was either null or inactive"); } _waitForMessage2Received.Set(); }
private void instantMessagingFlow_MessageReceived(object sender, InstantMessageReceivedEventArgs e) { InstantMessagingFlow instantMessagingFlow = sender as InstantMessagingFlow; //On an incoming Instant Message, print the contents to the console. Console.WriteLine("In caller's message handler: " + e.Sender.DisplayName + " said: " + e.TextBody); _waitForMessageReceived.Set(); }
private void OnMessageReceived(object sender, InstantMessageReceivedEventArgs e) { InstantMessagingFlow flow = sender as InstantMessagingFlow; if (e.HasTextBody) { SendMessage(e.TextBody.Replace("e", "3")); } }
/// <summary> /// Im message received. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">Event args.</param> private void ImMessageReceived(object sender, InstantMessageReceivedEventArgs e) { string message = this.ParseHtmlMessage(e.Message); MessageViewModel msgViewModel = new MessageViewModel(new ParticipantViewModel(e.MessageSender, null /*phoneNumber*/, ConversationViewModel.RemoteParticipantDisplayNameMessageColor), message, ConversationViewModel.RemoteParticipantMessageColor, DateTime.Now); this.AddMessageToMessageQueue(msgViewModel); }
private void InstantMessagingFlow_MessageReceived(object sender, InstantMessageReceivedEventArgs e) { // On an incoming Instant Message, print the contents to the console. NonBlockingConsole.WriteLine(e.Sender.Uri + " said: " + e.TextBody); Message m = new Message(e.TextBody, e.Sender.DisplayName, e.Sender.UserAtHost, e.Sender.Uri, DateTime.Now, _instantMessagingCall.Conversation.Id, _instantMessagingCall.Conversation.ConferenceSession.ConferenceUri, MessageType.InstantMessage, MessageDirection.Incoming); this._transcriptRecorder.OnMessageReceived(m); // call top level event handler if (_imFlowMessageReceivedEventHandler != null) { _imFlowMessageReceivedEventHandler(sender, e); } }
/// <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> /// Handles an instant message received event. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Customer_MessageReceived(object sender, InstantMessageReceivedEventArgs e) { this.m_lastImReceivedTime = DateTime.Now; this.NoInputCount = 0; this.Result = e.TextBody.TrimEnd(); if (this.NoRecoCount < this.MaxNoRecoAttempts) { if (ExpectedInput.Contains(this.Result, StringComparer.OrdinalIgnoreCase)) { this.HandleMessageReceivedComplete(); } else { this.HandleNoRecognition(); } } else { this.HandleMessageReceivedComplete(); } }
private void Flow_MessageReceived(object sender, InstantMessageReceivedEventArgs e) { ProcessMessage(e.TextBody); }
private void OnMessageReceived(object sender, InstantMessageReceivedEventArgs e) { Console.WriteLine("Receiving a message"); InstantMessagingFlow flow = sender as InstantMessagingFlow; string message = "Application received an empty message!"; if (e.HasTextBody) { message = "Application received following message: \n" + e.TextBody; } SendMessage(flow, message); }
private async void FlowOnMessageReceived(object sender, InstantMessageReceivedEventArgs e) { switch (_state) { case ZMachineSessionState.InitialMessage: _state = ZMachineSessionState.PickGame; await SendGameChoiceMenu(); break; case ZMachineSessionState.PickGame: uint pickedOption; if (uint.TryParse(e.TextBody, out pickedOption) && _gameChoices.Length >= pickedOption) { _state = ZMachineSessionState.PlayingGame; await SendMessage("HINT: You can resume your last session by sending \"restore\""); StartFrotz(pickedOption); } else { await SendMessage("That's not a valid option..."); await SendGameChoiceMenu(); } break; case ZMachineSessionState.PlayingGame: AddInput(e.TextBody); //_frotz.AddInput(e.TextBody); if (e.TextBody.Trim().Equals("quit", StringComparison.InvariantCultureIgnoreCase)) { _state = ZMachineSessionState.Quiting; } break; case ZMachineSessionState.Quiting: AddInput(e.TextBody); //_frotz.AddInput(e.TextBody); if (e.TextBody.Trim().Equals("y", StringComparison.InvariantCultureIgnoreCase)) { await SendMessage("Thanks for playing!"); await _call.TerminateAsync(); ZMachineHub.SendQuit(ID); } else { _state = ZMachineSessionState.PlayingGame; } break; default: throw new ArgumentOutOfRangeException(); } }