Beispiel #1
0
        protected override async Task PerformSendAfterWriteAsync(
            BackendABIHelper args,
            Stream stream,
            Int32 size,
            CancellationToken token,
            ResizableArray <Byte> buffer
            )
        {
            await args.WriteString(stream, this._statementName, token, buffer);

            await args.WriteString(stream, this._sql, token, buffer);

            var typesCount = this._typeIDs.GetLengthOrDefault();

            buffer.CurrentMaxCapacity = sizeof(Int16) + 4 * typesCount;
            var array = buffer.Array;
            var idx   = 0;

            array.WritePgInt16(ref idx, typesCount);
            if (typesCount > 0)
            {
                foreach (var typeID in this._typeIDs)
                {
                    array.WritePgInt32(ref idx, typeID);
                }
            }
            await stream.WriteAsync(array, 0, idx, token);
        }
Beispiel #2
0
        protected override async Task DoSendMessageAsync(
            BackendABIHelper args,
            Stream stream,
            Int32 size,
            CancellationToken token,
            ResizableArray <Byte> array
            )
        {
            // As documentation states, "For historical reasons, the very first message sent by the client (the startup message) has no initial message-type byte."
            // Hence we don't inherit the FrontEndMessageObjectWithCode class
            array.CurrentMaxCapacity = PREFIX;
            var idx = 0;

            array.Array
            .WritePgInt32(ref idx, size)
            .WritePgInt32(ref idx, this._protocolVersion);
            await stream.WriteAsync(array.Array, 0, PREFIX, token);

            foreach (var kvp in this._parameters)
            {
                await args.WriteString(stream, kvp.Key, token, array);

                await args.WriteString(stream, kvp.Value, token, array);
            }
            array.Array[0] = 0;
            await stream.WriteAsync(array.Array, 0, 1, token);
        }