public static void ClientPrivateMessage(ClientInstance instance, string parameters) { string[] args = parameters.Split(','); for (int i = 0; i < ServerHandler.activeClients.Count; i++) { if (args[0] == ServerHandler.activeClients[i].ID.ToString() && !String.IsNullOrEmpty(args[1])) { // Get the index of the client sending the message. int index = ServerMessage.FindClientKeysIndex(instance.client); // Send the message to the reciever. ServerMessage.ClientPrivateMessage( ServerHandler.activeClients[i].TCPClient, ConsoleColor.Yellow, args[1], ServerHandler.activeClients[index].ID, ServerHandler.activeClients[index].Username ); // Send a message to the sender to confirm the message has been sent. ServerMessage.ServerClientMessage(instance.client, ConsoleColor.Yellow, "Message has been sent."); } } }
public static void Execute() { for (int i = 0; i < ServerHandler.activeClients.Count; i++) { bool parse = int.TryParse(Commands.CommandArguments[0], out int outNum); if (parse && ServerHandler.activeClients[i].ID == outNum) { if (Commands.CommandArguments[1] != null) { ServerMessage.ServerClientMessage(ServerHandler.activeClients[i].TCPClient, ConsoleColor.Yellow, Commands.CommandArguments[1]); } } } }
public static bool VersionCheck(ClientInstance instance, string clientVersion) { // Check if versions do not match, if not close connection. if (clientVersion != Assembly.GetExecutingAssembly().GetName().Version.ToString()) { string message = String.Format("Your version of: {0} does not match the server version of: {1}", clientVersion, Assembly.GetExecutingAssembly().GetName().Version.ToString()); ServerMessage.ServerClientMessage(instance.client, ConsoleColor.Yellow, message); instance.client.Close(); return(false); } return(true); }