public void Disconnect() { world.UnregisterPlayer(player); player = null; if (ioThread != null) { if (ioThread.IsAlive) { ioThread.Abort(); } ioThread = null; } if (reader != null) { reader.Close(); reader = null; } if (writer != null) { writer.Close(); writer = null; } if (client != null) { client.Close(); client = null; } }