/// <summary> /// Parses the chat MSG. /// </summary> /// <param name = "strChatMsg">The STR chat MSG.</param> /// <returns></returns> private static ChatMsg ParseChatMsg(string strChatMsg) { try { //Type: [1], Channel: [], Player Name: [Fdgfisdgn], Sender GUID: [06800000021AF61B], Text: [CatchMe!] ChatMsg sMsg; int pos1 = strChatMsg.IndexOf("Type: [") + 7; int pos2 = strChatMsg.IndexOf("]", pos1); if (!(pos1 > 0 || pos2 > 0)) { return(new ChatMsg()); } sMsg.Type = (Constants.ChatType)Int32.Parse(strChatMsg.Substring(pos1, pos2 - pos1)); pos1 = strChatMsg.IndexOf("Channel: [") + 10; pos2 = strChatMsg.IndexOf("]", pos1); sMsg.Channel = strChatMsg.Substring(pos1, pos2 - pos1); pos1 = strChatMsg.IndexOf("Player Name: [") + 14; pos2 = strChatMsg.IndexOf("]", pos1); sMsg.Player = strChatMsg.Substring(pos1, pos2 - pos1); pos1 = strChatMsg.IndexOf("Sender GUID: [") + 14; pos2 = strChatMsg.IndexOf("]", pos1); strChatMsg.Substring(pos1, pos2 - pos1); pos1 = strChatMsg.IndexOf("Text: [") + 7; pos2 = pos1; while (true) { int tmp = strChatMsg.IndexOf("]", pos2 + 1); if (tmp == -1) { break; } pos2 = tmp; } sMsg.Msg = strChatMsg.Substring(pos1, pos2 - pos1); return(sMsg); } catch { var sMsg = new ChatMsg(); return(sMsg); } }
/// <summary> /// Finds the new messages. /// </summary> private void FindNewMessages() { for (int i = 0; i < 60; i++) { if (_listCurrentChat[i] != _listLastChat[i]) { ChatMsg msg = ParseChatMsg(_listCurrentChat[i]); if (NewChatMessage != null) { NewChatMessage(this, new GChatEventArgs { Msg = msg }); } _listCompleteChat.Add(msg); _listLastestChat.Add(msg); } } }
/// <summary> /// Parses the chat MSG. /// </summary> /// <param name = "strChatMsg">The STR chat MSG.</param> /// <returns></returns> private static ChatMsg ParseChatMsg(string strChatMsg) { try { //Type: [1], Channel: [], Player Name: [Fdgfisdgn], Sender GUID: [06800000021AF61B], Text: [CatchMe!] ChatMsg sMsg; int pos1 = strChatMsg.IndexOf("Type: [") + 7; int pos2 = strChatMsg.IndexOf("]", pos1); if (!(pos1 > 0 || pos2 > 0)) return new ChatMsg(); sMsg.Type = (Constants.ChatType) Int32.Parse(strChatMsg.Substring(pos1, pos2 - pos1)); pos1 = strChatMsg.IndexOf("Channel: [") + 10; pos2 = strChatMsg.IndexOf("]", pos1); sMsg.Channel = strChatMsg.Substring(pos1, pos2 - pos1); pos1 = strChatMsg.IndexOf("Player Name: [") + 14; pos2 = strChatMsg.IndexOf("]", pos1); sMsg.Player = strChatMsg.Substring(pos1, pos2 - pos1); pos1 = strChatMsg.IndexOf("Sender GUID: [") + 14; pos2 = strChatMsg.IndexOf("]", pos1); strChatMsg.Substring(pos1, pos2 - pos1); pos1 = strChatMsg.IndexOf("Text: [") + 7; pos2 = pos1; while (true) { int tmp = strChatMsg.IndexOf("]", pos2 + 1); if (tmp == -1) break; pos2 = tmp; } sMsg.Msg = strChatMsg.Substring(pos1, pos2 - pos1); return sMsg; } catch { var sMsg = new ChatMsg(); return sMsg; } }