Index: src/drive_lfss/command_console/command.cs =================================================================== --- src/drive_lfss/command_console/command.cs (revision 25) +++ src/drive_lfss/command_console/command.cs (working copy) @@ -18,6 +18,10 @@ namespace Drive_LFSS.CommandConsole_ { using Drive_LFSS; + using Drive_LFSS.Session_; + using System.Collections.Generic; + using System; + using Drive_LFSS.Packet_; //using System.Collections.Generic; //using System.Text; @@ -25,8 +29,11 @@ { public static void Exec(string _commandText) { - switch (_commandText) + string[] args = _commandText.Split(new string[] { " " }, 2, StringSplitOptions.RemoveEmptyEntries); + + switch (args[0]) { + case "announcement": Announcement(args[1]); break; case "exit": Exit(); break; default: { @@ -36,6 +43,38 @@ } } } + private static void Announcement(string _commandText) + { + string[] args = _commandText.Split(new string[] { " " }, 2, StringSplitOptions.RemoveEmptyEntries); + + if (args.Length == 2) + { + if (args[0] != "*") + { + ushort serverId = Convert.ToUInt16(args[1]); + + if (SessionList.sessionList.ContainsKey(serverId)) + { + SessionList.sessionList[serverId].session.AddToTcpSendingQueud(new Packet(Packet_Size.PACKET_SIZE_MST, Packet_Type.PACKET_MST_SEND_NORMAL_CHAT, new PacketMST(args[1]))); + } + else + { + Program.log.command("Unknow serverId: " + args[0] + "\r\n"); + } + } + else + { + foreach (KeyValuePair keyPair in SessionList.sessionList) + { + SessionList.sessionList[keyPair.Key].session.AddToTcpSendingQueud(new Packet(Packet_Size.PACKET_SIZE_MST, Packet_Type.PACKET_MST_SEND_NORMAL_CHAT, new PacketMST(args[1]))); + } + } + } + else + { + Program.log.command("Invalid command: " + _commandText + "\r\n"); + } + } private static void Exit() { Program.log.normal("Exiting Requested, Please Wait For All Thread Too Close...\n\r");