complete password protected servers

closes #2290
This commit is contained in:
Matthias Mailänder
2013-10-05 13:02:47 +02:00
parent a6cdcea414
commit b618fc7cc2
17 changed files with 229 additions and 81 deletions

View File

@@ -135,7 +135,7 @@ namespace OpenRA.Network
{
var len = reader.ReadInt32();
var client = reader.ReadInt32();
var buf = reader.ReadBytes( len );
var buf = reader.ReadBytes(len);
if (len == 0)
throw new NotImplementedException();
lock (this)

View File

@@ -27,8 +27,10 @@ namespace OpenRA.Network
public readonly string Host;
public readonly int Port;
public readonly string Password = "";
public string ServerError = "Server is not responding.";
public string ServerError = "Server is not responding";
public bool AuthenticationFailed = false;
public int NetFrameNumber { get; private set; }
public int LocalFrameNumber;
@@ -52,10 +54,11 @@ namespace OpenRA.Network
Connection.Send(i, new List<byte[]>());
}
public OrderManager(string host, int port, IConnection conn)
public OrderManager(string host, int port, string password, IConnection conn)
{
this.Host = host;
this.Port = port;
Host = host;
Port = port;
Password = password;
Connection = conn;
syncReport = new SyncReport(this);
}

14
OpenRA.Game/Network/UnitOrders.cs Executable file → Normal file
View File

@@ -51,9 +51,11 @@ namespace OpenRA.Network
Game.AddChatLine(Color.White, "(player {0})".F(clientId), order.TargetString);
break;
}
case "Message": // Server message
Game.AddChatLine(Color.White, "Server", order.TargetString);
break;
case "Disconnected": /* reports that the target player disconnected */
{
var client = orderManager.LobbyInfo.ClientWithIndex(clientId);
@@ -146,7 +148,7 @@ namespace OpenRA.Network
{
Client = info,
Mods = localMods,
Password = "Foo"
Password = orderManager.Password
};
orderManager.IssueOrder(Order.HandshakeResponse(response.Serialize()));
@@ -156,6 +158,14 @@ namespace OpenRA.Network
case "ServerError":
{
orderManager.ServerError = order.TargetString;
orderManager.AuthenticationFailed = false;
break;
}
case "AuthenticationError":
{
orderManager.ServerError = order.TargetString;
orderManager.AuthenticationFailed = true;
break;
}
@@ -195,11 +205,13 @@ namespace OpenRA.Network
break;
}
case "Ping":
{
orderManager.IssueOrder(Order.Pong(order.TargetString));
break;
}
default:
{
if (!order.IsImmediate)