Add protocol version check
This commit is contained in:
parent
7593985ceb
commit
dbeb1d483a
|
@ -60,6 +60,7 @@
|
|||
<Compile Include="Protocol\Data.cs" />
|
||||
<Compile Include="Protocol\EventData.cs" />
|
||||
<Compile Include="Protocol\EventDataArgs.cs" />
|
||||
<Compile Include="Protocol\Protocol.cs" />
|
||||
<Compile Include="Protocol\RequestData.cs" />
|
||||
<Compile Include="Protocol\RequestResult.cs" />
|
||||
<Compile Include="Protocol\ResultData.cs" />
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace Galactic_Colors_Control_Common.Protocol
|
||||
using System;
|
||||
|
||||
namespace Galactic_Colors_Control_Common.Protocol
|
||||
{
|
||||
/// <summary>
|
||||
/// Packet Master Class
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
using System;
|
||||
|
||||
namespace Galactic_Colors_Control_Common.Protocol
|
||||
{
|
||||
public static class Protocol
|
||||
{
|
||||
public static Version version = new Version(0, 1); //Protocol version
|
||||
}
|
||||
}
|
|
@ -52,4 +52,5 @@ AnyMessage;Aucun message;Any message
|
|||
MustBeConnected;Doit etre connecte;Must be connected
|
||||
Create;Creer;Create
|
||||
Name;Nom;Name
|
||||
Size;Taille;Size
|
||||
Size;Taille;Size
|
||||
Version;Utiliser la version;Use version
|
Can't render this file because it has a wrong number of fields in line 39.
|
|
@ -95,7 +95,7 @@ namespace Galactic_Colors_Control_Console
|
|||
string username = Console.ReadLine();
|
||||
if (username.Length > 3)
|
||||
{
|
||||
ResultData res = client.Request(new string[2] { "connect", username });
|
||||
ResultData res = client.Request(new string[3] { "connect", username, Protocol.version.ToString() });
|
||||
if(res.type == ResultTypes.OK) { connected = true; logger.Write("Identification", Logger.logType.info); }
|
||||
else
|
||||
{
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace Galactic_Colors_Control_GUI.States
|
|||
{
|
||||
if (username.Length > 3)
|
||||
{
|
||||
ResultData res = Game.singleton.client.Request(new string[2] { "connect", username });
|
||||
ResultData res = Game.singleton.client.Request(new string[3] { "connect", username, Protocol.version.ToString() });
|
||||
if (res.type == ResultTypes.OK)
|
||||
{
|
||||
Game.singleton.gameState = new PartyState();
|
||||
|
|
|
@ -9,20 +9,23 @@ namespace Galactic_Colors_Control_Server.Commands
|
|||
{
|
||||
public string Name { get { return "connect"; } }
|
||||
public string DescText { get { return "Gets an username."; } }
|
||||
public string HelpText { get { return "Use 'connect [username]' to start identification"; } }
|
||||
public string HelpText { get { return "Use 'connect [username] [version]' to start identification"; } }
|
||||
public Manager.CommandGroup Group { get { return Manager.CommandGroup.root; } }
|
||||
public bool IsServer { get { return false; } }
|
||||
public bool IsClient { get { return true; } }
|
||||
public bool IsClientSide { get { return false; } }
|
||||
public bool IsNoConnect { get { return true; } }
|
||||
public int minArgs { get { return 1; } }
|
||||
public int maxArgs { get { return 1; } }
|
||||
public int minArgs { get { return 2; } }
|
||||
public int maxArgs { get { return 2; } }
|
||||
|
||||
public RequestResult Execute(string[] args, Socket soc, bool server = false)
|
||||
{
|
||||
if (Utilities.IsConnect(soc))
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("Connected"));
|
||||
|
||||
if (args[2] != Protocol.version.ToString()) //Check client protocol version
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("Version", Protocol.version.ToString()));
|
||||
|
||||
if (args[1].Length < 3)
|
||||
return new RequestResult(ResultTypes.Error, Common.Strings("TooShort"));
|
||||
|
||||
|
|
Reference in New Issue