public static void ReceiveMessage(Message chatMessage) { bool isChatWindowOpen = IsChatWindowOpen(chatMessage.id); ChatWindow foundChatWindow = GetChatWindow(chatMessage.id); if (foundChatWindow != null) { foundChatWindow.AddChatMessage(foundChatWindow.GetContactName(), chatMessage.message); if (!foundChatWindow.IsFocused & Personal.USER_INFO.status == Convert.ToInt16(UserStatus.Available)) { Player.PlaySound(Identifiers.NEW_MSG); if (!isChatWindowOpen) { string truncatedMessage = chatMessage.message.Length <= 20 ? chatMessage.message : chatMessage.message.Substring(0, 20) + "..."; Notification.NotificationManager.Showpopup(foundChatWindow.GetContactName(), truncatedMessage, foundChatWindow); } } FlashWindowManager.FlashWindow(foundChatWindow, 5); } }