public void ParseReceivedMessage(string text) { Message message = null; try { message = Message.ParseReceivedMessage(text); } catch (ArgumentException ae) { /** shh! */ return; } if (message.Recipient != username) { throw new InvalidOperationException("Recieved stray message ::" + message); } // To make the code cleaner this would be delegated to an interface foreach (string fileNameWithPath in Directory.EnumerateFiles(Utilities.Configuration.FIFO_FOLDER)) { if (fileNameWithPath == Path.Combine(Configuration.FIFO_FOLDER, message.Sender) || fileNameWithPath == Utilities.Configuration.BROADCAST_CHANNEL) { continue; } using (StreamWriter sw = File.AppendText(fileNameWithPath)) { sw.WriteLine(message); } } }
public void ParseReceivedMessage(string text) { Message message = null; try { message = Message.ParseReceivedMessage(text); } catch (ArgumentException ae) { chatApplication.AddChatErrorLine(username, $@"Command failed :: {ae.Message}"); return; } if (message.Recipient == username || message.Recipient == Configuration.BROADCAST_CHANNELNAME) { chatApplication.AppendParsedMessageToChat(username, message); } else { chatApplication.AddChatErrorLine(username, "Received stray message ::" + message); } }