// ChatFromViewerOut: outgoing ChatFromViewer delegate; check for Analyst commands private static Packet ChatFromViewerOut(Packet packet, IPEndPoint sim) { // deconstruct the packet Hashtable blocks = PacketUtility.Unbuild(packet); string message = DataConvert.toChoppedString(PacketUtility.GetField(blocks, "ChatData", "Message")); if (message.Length > 1 && message[0] == '/') { string[] words = message.Split(' '); if (commandDelegates.Contains(words[0])) { // this is an Analyst command; act on it and drop the chat packet ((CommandDelegate)commandDelegates[words[0]])(words); return(null); } } if (loggedPackets.Contains("ChatFromViewer") || modifiedPackets.Contains("ChatFromViewer")) { // user has asked to log or modify this packet return(Analyze(packet, sim, Direction.Outgoing)); } else { // return the packet unmodified return(packet); } }
private static Packet ChatFromSimulator(Packet packet, IPEndPoint sim) { // deconstruct the packet Hashtable blocks = PacketUtility.Unbuild(packet); string message = DataConvert.toChoppedString(PacketUtility.GetField(blocks, "ChatData", "Message")); string name = DataConvert.toChoppedString(PacketUtility.GetField(blocks, "ChatData", "FromName")); byte audible = (byte)PacketUtility.GetField(blocks, "ChatData", "Audible"); byte type = (byte)PacketUtility.GetField(blocks, "ChatData", "ChatType"); // if this was a normal, audible message, write it to the console if (audible != 0 && (type == 0 || type == 1 || type == 2)) { Console.WriteLine(name + ": " + message); } // return the packet unmodified return(packet); }