public override void write(ConnectionHandlerContext ctx, object msg) { if (msg is ByteBuf) { tempBuf.Clear(); ByteBuf buf = (ByteBuf)msg; if (LengthBytes == 2) { ushort len = (ushort)buf.remainBytes(); tempBuf.writeUInt16(len); } else if (LengthBytes == 4) { uint len = (uint)buf.remainBytes(); tempBuf.writeUInt32(len); } else if (LengthBytes == 8) { ulong len = (ulong)buf.remainBytes(); tempBuf.writeUInt64(len); } tempBuf.writeBytes(buf); ctx.fireWrite(tempBuf); } }