List Server Example: warn gameserver if it tries to send a too big message which would be rejected by List Server

This commit is contained in:
vis2k 2019-04-04 13:09:25 +02:00
parent 401455197f
commit 5226ed64de

View File

@ -109,11 +109,16 @@ void SendStatus()
char[] titleChars = gameServerTitle.ToCharArray(); char[] titleChars = gameServerTitle.ToCharArray();
writer.Write((ushort)titleChars.Length); writer.Write((ushort)titleChars.Length);
writer.Write(titleChars); writer.Write(titleChars);
// send it
writer.Flush(); writer.Flush();
// list server only allows up to 128 bytes per message
if (writer.BaseStream.Position <= 128)
{
// send it
gameServerToListenConnection.Send(((MemoryStream)writer.BaseStream).ToArray()); gameServerToListenConnection.Send(((MemoryStream)writer.BaseStream).ToArray());
} }
else Debug.LogError("[List Server] List Server will reject messages longer than 128 bytes. Please use a shorter title.");
}
void TickGameServer() void TickGameServer()
{ {