1
0
Fork 0

Ajout de verification IsClientSide

This commit is contained in:
sheychen 2016-10-11 12:09:51 +02:00
parent 0f42c0b39e
commit b3783627ba
15 changed files with 34 additions and 12 deletions

View File

@ -10,6 +10,7 @@ namespace Galactic_Colors_Control_Server.Commands
public string HelpText { get { return "Use /clear to execute Console.Clear()."; } } public string HelpText { get { return "Use /clear to execute Console.Clear()."; } }
public bool IsServer { get { return true; } } public bool IsServer { get { return true; } }
public bool IsClient { get { return true; } } public bool IsClient { get { return true; } }
public bool IsClientSide { get { return true; } }
public bool IsNoConnect { get { return true; } } public bool IsNoConnect { get { return true; } }
public int minArgs { get { return 0; } } public int minArgs { get { return 0; } }
public int maxArgs { get { return 0; } } public int maxArgs { get { return 0; } }

View File

@ -10,6 +10,7 @@ namespace Galactic_Colors_Control_Server.Commands
public string HelpText { get { return "Use /close to stop connection process"; } } public string HelpText { get { return "Use /close to stop connection process"; } }
public bool IsServer { get { return true; } } public bool IsServer { get { return true; } }
public bool IsClient { get { return false; } } public bool IsClient { get { return false; } }
public bool IsClientSide { get { return false; } }
public bool IsNoConnect { get { return false; } } public bool IsNoConnect { get { return false; } }
public int minArgs { get { return 0; } } public int minArgs { get { return 0; } }
public int maxArgs { get { return 0; } } public int maxArgs { get { return 0; } }

View File

@ -11,6 +11,7 @@ namespace Galactic_Colors_Control_Server.Commands
public string HelpText { get { return "Use /connect [username] to start identification"; } } public string HelpText { get { return "Use /connect [username] to start identification"; } }
public bool IsServer { get { return false; } } public bool IsServer { get { return false; } }
public bool IsClient { get { return true; } } public bool IsClient { get { return true; } }
public bool IsClientSide { get { return false; } }
public bool IsNoConnect { get { return true; } } public bool IsNoConnect { get { return true; } }
public int minArgs { get { return 1; } } public int minArgs { get { return 1; } }
public int maxArgs { get { return 1; } } public int maxArgs { get { return 1; } }

View File

@ -10,6 +10,7 @@ namespace Galactic_Colors_Control_Server.Commands
public string HelpText { get { return "Use /count to show connected clients count and size"; } } public string HelpText { get { return "Use /count to show connected clients count and size"; } }
public bool IsServer { get { return true; } } public bool IsServer { get { return true; } }
public bool IsClient { get { return false; } } public bool IsClient { get { return false; } }
public bool IsClientSide { get { return false; } }
public bool IsNoConnect { get { return false; } } public bool IsNoConnect { get { return false; } }
public int minArgs { get { return 0; } } public int minArgs { get { return 0; } }
public int maxArgs { get { return 0; } } public int maxArgs { get { return 0; } }

View File

@ -10,6 +10,7 @@ namespace Galactic_Colors_Control_Server.Commands
public string HelpText { get { return "Use /exit to stop actual program."; } } public string HelpText { get { return "Use /exit to stop actual program."; } }
public bool IsServer { get { return true; } } public bool IsServer { get { return true; } }
public bool IsClient { get { return true; } } public bool IsClient { get { return true; } }
public bool IsClientSide { get { return false; } }
public bool IsNoConnect { get { return true; } } public bool IsNoConnect { get { return true; } }
public int minArgs { get { return 0; } } public int minArgs { get { return 0; } }
public int maxArgs { get { return 0; } } public int maxArgs { get { return 0; } }

View File

@ -12,6 +12,7 @@ namespace Galactic_Colors_Control_Server.Commands
public string HelpText { get { return "Use /help [command] to display command help."; } } public string HelpText { get { return "Use /help [command] to display command help."; } }
public bool IsServer { get { return true; } } public bool IsServer { get { return true; } }
public bool IsClient { get { return true; } } public bool IsClient { get { return true; } }
public bool IsClientSide { get { return false; } }
public bool IsNoConnect { get { return false; } } public bool IsNoConnect { get { return false; } }
public int minArgs { get { return 0; } } public int minArgs { get { return 0; } }
public int maxArgs { get { return 1; } } public int maxArgs { get { return 1; } }

View File

@ -9,6 +9,7 @@ namespace Galactic_Colors_Control_Server.Commands
string HelpText { get; } string HelpText { get; }
bool IsServer { get; } bool IsServer { get; }
bool IsClient { get; } bool IsClient { get; }
bool IsClientSide { get; }
bool IsNoConnect { get; } bool IsNoConnect { get; }
int minArgs { get; } int minArgs { get; }
int maxArgs { get; } int maxArgs { get; }

View File

@ -12,6 +12,7 @@ namespace Galactic_Colors_Control_Server.Commands
public string HelpText { get { return "Use /kick [username] <reason> to kick client from server."; } } public string HelpText { get { return "Use /kick [username] <reason> to kick client from server."; } }
public bool IsServer { get { return true; } } public bool IsServer { get { return true; } }
public bool IsClient { get { return false; } } public bool IsClient { get { return false; } }
public bool IsClientSide { get { return false; } }
public bool IsNoConnect { get { return true; } } public bool IsNoConnect { get { return true; } }
public int minArgs { get { return 1; } } public int minArgs { get { return 1; } }
public int maxArgs { get { return 2; } } public int maxArgs { get { return 2; } }

View File

@ -10,6 +10,7 @@ namespace Galactic_Colors_Control_Server.Commands
public string HelpText { get { return "Use /list to display all connected client username or IP."; } } public string HelpText { get { return "Use /list to display all connected client username or IP."; } }
public bool IsServer { get { return true; } } public bool IsServer { get { return true; } }
public bool IsClient { get { return false; } } public bool IsClient { get { return false; } }
public bool IsClientSide { get { return false; } }
public bool IsNoConnect { get { return false; } } public bool IsNoConnect { get { return false; } }
public int minArgs { get { return 0; } } public int minArgs { get { return 0; } }
public int maxArgs { get { return 0; } } public int maxArgs { get { return 0; } }

View File

@ -10,6 +10,7 @@ namespace Galactic_Colors_Control_Server.Commands
public string HelpText { get { return "Use /loglevel [loglevel] to change Loglevel."; } } public string HelpText { get { return "Use /loglevel [loglevel] to change Loglevel."; } }
public bool IsServer { get { return true; } } public bool IsServer { get { return true; } }
public bool IsClient { get { return false; } } public bool IsClient { get { return false; } }
public bool IsClientSide { get { return true; } }
public bool IsNoConnect { get { return false; } } public bool IsNoConnect { get { return false; } }
public int minArgs { get { return 1; } } public int minArgs { get { return 1; } }
public int maxArgs { get { return 1; } } public int maxArgs { get { return 1; } }

View File

@ -35,22 +35,30 @@ namespace Galactic_Colors_Control_Server.Commands
if (commands.ContainsKey(args[0])) if (commands.ContainsKey(args[0]))
{ {
ICommand command = commands[args[0]]; ICommand command = commands[args[0]];
if (CanAccess(command,soc,server)) if (CanAccess(command, soc, server))
{ {
if(args.Length > command.minArgs) if (command.IsClientSide)
{ {
if(args.Length - 1 <= command.maxArgs) Utilities.Return("It's a client side command", soc, server);
{
command.Execute(args, soc, server);
}
else
{
Utilities.Return("Command " + command.Name + " require at most " + command.minArgs + " argument(s).", soc, server);
}
} }
else else
{ {
Utilities.Return("Command " + command.Name + " require at least " + command.minArgs + " argument(s).", soc, server); if (args.Length > command.minArgs)
{
if (args.Length - 1 <= command.maxArgs)
{
command.Execute(args, soc, server);
}
else
{
Utilities.Return("Command " + command.Name + " require at most " + command.minArgs + " argument(s).", soc, server);
}
}
else
{
Utilities.Return("Command " + command.Name + " require at least " + command.minArgs + " argument(s).", soc, server);
}
} }
} }
else else

View File

@ -10,6 +10,7 @@ namespace Galactic_Colors_Control_Server.Commands
public string HelpText { get { return "Use /open to restart connection process"; } } public string HelpText { get { return "Use /open to restart connection process"; } }
public bool IsServer { get { return true; } } public bool IsServer { get { return true; } }
public bool IsClient { get { return false; } } public bool IsClient { get { return false; } }
public bool IsClientSide { get { return false; } }
public bool IsNoConnect { get { return false; } } public bool IsNoConnect { get { return false; } }
public int minArgs { get { return 0; } } public int minArgs { get { return 0; } }
public int maxArgs { get { return 0; } } public int maxArgs { get { return 0; } }

View File

@ -9,13 +9,14 @@ namespace Galactic_Colors_Control_Server.Commands
public string HelpText { get { return "Use /ping to display our ping."; } } public string HelpText { get { return "Use /ping to display our ping."; } }
public bool IsServer { get { return false; } } public bool IsServer { get { return false; } }
public bool IsClient { get { return true; } } public bool IsClient { get { return true; } }
public bool IsClientSide { get { return true; } }
public bool IsNoConnect { get { return false; } } public bool IsNoConnect { get { return false; } }
public int minArgs { get { return 0; } } public int minArgs { get { return 0; } }
public int maxArgs { get { return 0; } } public int maxArgs { get { return 0; } }
public void Execute(string[] args, Socket soc, bool server = false) public void Execute(string[] args, Socket soc, bool server = false)
{ {
Utilities.Return("It's a client side command" ,soc ,server);
} }
} }
} }

View File

@ -10,6 +10,7 @@ namespace Galactic_Colors_Control_Server.Commands
public string HelpText { get { return "Use /status to display server actual status."; } } public string HelpText { get { return "Use /status to display server actual status."; } }
public bool IsServer { get { return true; } } public bool IsServer { get { return true; } }
public bool IsClient { get { return false; } } public bool IsClient { get { return false; } }
public bool IsClientSide { get { return false; } }
public bool IsNoConnect { get { return false; } } public bool IsNoConnect { get { return false; } }
public int minArgs { get { return 0; } } public int minArgs { get { return 0; } }
public int maxArgs { get { return 0; } } public int maxArgs { get { return 0; } }

View File

@ -10,6 +10,7 @@ namespace Galactic_Colors_Control_Server.Commands
public string HelpText { get { return "Use /time to display server time. (format is server dependent)"; } } public string HelpText { get { return "Use /time to display server time. (format is server dependent)"; } }
public bool IsServer { get { return true; } } public bool IsServer { get { return true; } }
public bool IsClient { get { return true; } } public bool IsClient { get { return true; } }
public bool IsClientSide { get { return false; } }
public bool IsNoConnect { get { return false; } } public bool IsNoConnect { get { return false; } }
public int minArgs { get { return 0; } } public int minArgs { get { return 0; } }
public int maxArgs { get { return 0; } } public int maxArgs { get { return 0; } }