Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Craft.Net Example Proxy

SirCmpwn edited this page Dec 27, 2012 · 1 revision

Here's a simple proxy, with no encryption:

public void Proxy(NetworkStream client, NetworkStream server)
{
    var clientStream = new MinecraftStream(client);
    var serverStream = new MinecraftStream(server);
    while (true)
    {
        if (client.DataAvailable)
        {
            var packet = PacketReader.ReadPacket(clientStream);
            packet.WriteTo(serverStream);
        }
        if (server.DataAvailable)
        {
            var packet = PacketReader.ReadPacket(serverStream);
            packet.WriteTo(clientStream);
        }
        Thread.Sleep(1);
    }
}
Clone this wiki locally