Hi,
I am looking for a TCP or HTTP networking library similar to Lidgren (UDP).
This is primarily for sending game map data and potentially other large messages from Server to Client.
I do want to keep Lidgren for my chat messages, player position, small fast updates etc. I especially love the flow of data and the library usage in general, so any libraries of a similar style would be excellent. Preferably something open source, free and reliable.
I also must be able to swap between localhost and an ip address with ease, like Lidgren, as I run a server for singleplayer/mp/lan.
My game maps are similar to minecraft, but it is 2d and only one Z-level, so i'm sending a jagged array of Tile object data (currently only enum TileID.Grass) down the pipe to the Client. Problem is if i'm sending a large map 1024 x 1024 tiles down the to client that's quite a lot of data, and Lidgren is relatively slow to build the writes (before the message is even sent!). It is fine when i'm using smaller maps < 512 x 512 ( xTiles * yTiles ).
I know about chunking and will look into implementing this later, whilst taking into account the user's position in the world to only send nearby chunks.
An example of my code that can be slow:
private void WriteWorld(NetOutgoingMessage outgoing)
{
try
{
var world = WorldManager.Instance.CurrentWorld;
outgoing.Write(world.XTiles);
outgoing.Write(world.YTiles);
for (int x = 0; x < world.XTiles; x++)
{
for (int y = 0; y < world.YTiles; y++)
{
// Write Tile obj data
outgoing.Write((int)world.Tiles[x][y]); // <-------- Slow here when xTiles and yTiles are each > 512 !
}
}
}
catch (Exception ex)
{
// log send error
}
}
I'd love to hear from you guys, especially if any of you have come across a similar challenge.