private void ProcessCommand(ClientConnection client, string[] args) { if (args.Length < 1) return; if (args.Length >= 2 && args[0].ToUpper().Equals("NICK")) { if(args[1].Equals("") || args[1].Equals(" ") || args[1].Equals(null)) { client.SendData("<Server> Invalid characters (Spaces?) in username. Allowed characters are a-z, A-Z, 0-9, _, and -"); client.SendData("The nick you tried to set is: <" + args[1] + ">"); } if (args[1].ToLower().Equals("server") || args[1].ToLower().Contains("admin")) { client.SendData("<Server> That nick is reserved."); } else if (Nicks.ContainsValue(args[1])) { client.SendData("<Server> That nick is already taken."); } else if (Regex.IsMatch(args[1], @"^[a-zA-Z0-9_\-]")) { Server.Broadcast("<Server> " + Nicks[client.ClientID] + " changed nick to " + args[1] + "."); Nicks[client.ClientID] = args[1]; } else { client.SendData("<Server> Invalid characters in username. Allowed characters are a-z, A-Z, 0-9, _, and -"); } } else if (args[0].ToUpper().Equals("DISCONNECT")) { if (args.Length > 1) { string quitReason = ""; for (int i = 1; i < args.Length; i++) { quitReason += args[i] + " "; } client.Disconnect(quitReason); } else { client.Disconnect(null); } } }
internal void ProcessIncominData(string data, ClientConnection connection) { if (data == null) { connection.Disconnect(); } else { if (OnClientInputEvent != null) { OnClientInputEvent(connection, data); } } }