if (dataStream[1] == (byte)Codes.DO && dataStream[2] == (byte)Codes.COMPRESS2)
{
ch.Send(new byte[] { (byte)Codes.IAC, (byte)Codes.SB, (byte)Codes.COMPRESS2, (byte)Codes.IAC, (byte)Codes.SE });
ch.MCCP = true;
ch.OutputStream = new MemoryStream();
ch.ZippedStream = new ZlibStream(ch.OutputStream, CompressionMode.Compress, CompressionLevel.BestCompression);
//ch.Send("Test\r\n");
//ch.Send("Test\r\n");
return true;
}
public static byte[] Compress(CharData ch, byte[] comp)
{
Global.Add_Log_Entry(0, "Entering data: " + comp.Length.ToString());
Global.Add_Log_Entry(0, "Compress Called: " + Encoding.UTF8.GetString(comp));
ch.ZippedStream.Write(comp, 0, comp.Length);
byte[] rByte = ch.OutputStream.ToArray();
Global.Add_Log_Entry(0, "Exiting data: " + rByte.Length.ToString());
return rByte;
}
I'm running into one of two problems now though. After the first string is sent to (it displays properly) everything else that displays is garbage characters. Or the client doesn't display anything (despite being compressed properly I believe). I was speaking with a member whom suggested I follow the Zstream to check for any non compressed characters being inserted but I did that and, after wading through A LOT of zlib garbage =D, I didn't find anything.
So I thought I would see if the MUD community could offer any advice on where to look, or possibly a working MCCP implementation in a C# codebase I could examine (Google's yet to return one).