server debug-prints

This commit is contained in:
Bob
2010-01-25 19:39:23 +13:00
parent dfbca88f4a
commit 3aa40c36cf
4 changed files with 31 additions and 13 deletions

View File

@@ -73,9 +73,6 @@ namespace OpenRA.Server
case ReceiveState.Data:
{
// if (bytes.Length > 0)
// Console.WriteLine("{0} bytes", bytes.Length);
Server.DispatchOrders(this, Frame, bytes);
ExpectLength = 8;
State = ReceiveState.Header;

27
OpenRA.Server/Exts.cs Executable file
View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
namespace OpenRA.Server
{
static class Exts
{
public static void Write( this Stream s, byte[] data )
{
s.Write( data, 0, data.Length );
}
public static byte[] Read( this Stream s, int len )
{
var data = new byte[ len ];
s.Read( data, 0, len );
return data;
}
public static IEnumerable<T> Except<T>( this IEnumerable<T> ts, T t )
{
return ts.Except( new[] { t } );
}
}
}

View File

@@ -49,6 +49,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Connection.cs" />
<Compile Include="Exts.cs" />
<Compile Include="Server.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ServerOrder.cs" />

View File

@@ -91,8 +91,8 @@ namespace OpenRA.Server
State = Session.ClientState.NotReady
});
Console.WriteLine("Accepted connection from {0}.",
newConn.socket.RemoteEndPoint);
Console.WriteLine("Client {0}: Accepted connection from {1}",
newConn.PlayerIndex, newConn.socket.RemoteEndPoint);
SendChat(newConn, "has joined the game.");
@@ -343,6 +343,7 @@ namespace OpenRA.Server
if (!dict.TryGetValue(cmdName, out a))
return false;
Console.WriteLine( "Client {0} sent server command: {1}", conn.PlayerIndex, cmd );
return a(cmdValue);
}
@@ -434,7 +435,6 @@ namespace OpenRA.Server
public static void DropClient(Connection toDrop, Exception e)
{
Console.WriteLine("Client dropped: {0}.", toDrop.socket.RemoteEndPoint);
//Console.WriteLine(e.ToString());
conns.Remove(toDrop);
SendChat(toDrop, "Connection Dropped");
@@ -454,13 +454,6 @@ namespace OpenRA.Server
else SyncLobbyInfo();
}
public static void Write(this Stream s, byte[] data) { s.Write(data, 0, data.Length); }
public static byte[] Read(this Stream s, int len) { var data = new byte[len]; s.Read(data, 0, len); return data; }
public static IEnumerable<T> Except<T>(this IEnumerable<T> ts, T t)
{
return ts.Except(new[] { t });
}
static void OnServerEmpty()
{
Console.WriteLine("Server emptied out; doing a bit of housekeeping to prepare for next game..");