Example #1
0
        private async Task WriteEscapedString(string str, CancellationToken cancellationToken)
        {
            int cue = 0;

            for (int i = 0; i < str.Length; i++)
            {
                byte[] escapedChar = StompOctets.EscapeOctet(str[i]);

                if (escapedChar != null)
                {
                    await _writer.WriteAsync(str, cue, i - cue, cancellationToken);

                    await _writer.WriteAsync(escapedChar, cancellationToken);

                    cue = i + 1;
                }
            }
            await _writer.WriteAsync(str, cue, str.Length - cue, cancellationToken);
        }