Ejemplo n.º 1
0
        private void WriteMessageToTranscript(Message message)
        {
            //adds a line for the received or sent message
            TranscriptItem lineItem = new TranscriptItem(message.TimeStamp, message.SenderDisplayName, message.SenderUri, message.Modality.ToString(), message.Content);
            _viewModel.MessageHistory.Add(lineItem);

            //manually scrows down to the last added message
            listBoxHistory.UpdateLayout();
            scrollViewerMessageLog.ScrollToVerticalOffset(listBoxHistory.ActualHeight);
        }
Ejemplo n.º 2
0
 // TODO: Make private later and use ConversationContext channel to write data
 void ShowIncomingTranscriptMessage(Message message)
 {
     WriteMessageToTranscript(message);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Parses context data into List of Messages based on format:
        /// [SenderDisplayName ([email protected])(sip:[email protected])][ConversationId:12345678][ConferenceUri:[email protected];conf][TimeStamp][MessageType][MessageDirection][MessageContent];;
        /// </summary>
        /// <param name="contextData"></param>
        /// <returns></returns>
        private List<Message> ParseMessagesFromContextData(string contextData)
        {
            List<Message> transcriptMessages = new List<Message>();

            // Split messages
            char[] transcriptMessagesDelimiter = { ';', ';' };
            string[] transcriptMessageData = contextData.Split(transcriptMessagesDelimiter);

            char[] messagePropertyDelimiter = { ']', '[' };
            char[] messageSenderInfoDelimiter = { '(' };
            foreach (string s in transcriptMessageData)
            {
                // Split message content
                string senderInfo = "null";
                string senderDisplayName = "null";
                string senderAlias = "null";
                string senderUri = "null";
                string conversationId = "null";
                string conferenceUri = "null";
                string timeStamp = DateTime.Now.ToString();
                string messageType = "Info";
                string messageDirection = "Incoming";
                string messageContent = "null";

                string[] messageProperties = s.Split(messagePropertyDelimiter);
                // Verify 7 items in messageProperties
                if (messageProperties.Length == 7)
                {
                    senderInfo = messageProperties[0].Substring(1);
                    conversationId = messageProperties[1].Substring(1);
                    conferenceUri = messageProperties[2].Substring(1);
                    timeStamp = messageProperties[3].Substring(1);
                    messageType = messageProperties[4].Substring(1);
                    messageDirection = messageProperties[5].Substring(1);
                    messageContent = messageProperties[6].Substring(1);

                    if (senderInfo.Contains('('))
                    {
                        string[] senderInfoItems = senderInfo.Split(messageSenderInfoDelimiter);
                        senderDisplayName = senderInfoItems[0].Trim();
                        senderAlias = senderInfoItems[1].Substring(0, senderInfoItems[1].Length - 1).Trim();
                        senderAlias = senderInfoItems[2].Substring(0, senderInfoItems[2].Length - 1).Trim();
                    }
                    else
                    {
                        senderDisplayName = senderInfo.Trim();
                    }
                }
                else
                {
                    // TODO: Error
                    continue;
                }

                MessageModality modality = MessageModality.Info;
                Enum.TryParse<MessageModality>(messageType, true, out modality);
                MessageDirection direction = MessageDirection.Incoming;
                Enum.TryParse<MessageDirection>(messageDirection, true, out direction);
                Message m = new Message(messageContent, senderDisplayName, senderAlias, senderUri, DateTime.Parse(timeStamp), conversationId, conferenceUri, modality, direction);
                transcriptMessages.Add(m);
            } // loop

            return transcriptMessages;
        }