internal async Task WritePassword(byte[] payload, int offset, int count, bool async)
{
if (WriteBuffer.WriteSpaceLeft < sizeof(byte) + sizeof(int))
{
await WriteBuffer.Flush(async);
}
WriteBuffer.WriteByte(FrontendMessageCode.Password);
WriteBuffer.WriteInt32(sizeof(int) + count);
if (count <= WriteBuffer.WriteSpaceLeft)
{
// The entire array fits in our WriteBuffer, copy it into the WriteBuffer as usual.
WriteBuffer.WriteBytes(payload, offset, count);
return;
}
await WriteBuffer.Flush(async);
await WriteBuffer.DirectWrite(payload, offset, count, async);
}