Example #1
0
        internal Task Handle_Deliver(ReadOnlySequence <byte> arguments)
        {
            var reader = new CustomBufferReader(arguments);

            pendingDelivery = new DeliverState
            {
                ConsumerTag = reader.ReadShortString(),
                DeliveryTag = reader.ReadUInt64(),
                Redelivered = Convert.ToBoolean(reader.ReadByte()),
                Exchange    = reader.ReadShortString(),
                RoutingKey  = reader.ReadShortString()
            };

            return(Task.CompletedTask);
        }
Example #2
0
        private async Task Handle_Close(ReadOnlySequence <byte> arguments)
        {
            IsOpen = false;

            await methods.Send_CloseOk().ConfigureAwait(false);

            if (replyIsExpected)
            {
                SendReply();
            }

            void SendReply()
            {
                var reader = new CustomBufferReader(arguments);

                var replyCode = reader.ReadUInt16();
                var replyText = reader.ReadShortString();

                var method = reader.ReadUInt32();

                var classId  = method >> 16;
                var methodId = method << 16 >> 16;

                var exception = new Exception($"Channel Closed: {replyCode} {replyText}. ClassId: {classId} MethodId: {methodId}");

                replyHandler(replyTaskCompletionSource, default, exception);
Example #3
0
        private void Handle_CancelOk(object tcs, ReadOnlySequence <byte> arguments, Exception exception)
        {
            var cancelOk = (TaskCompletionSource <string>)tcs;

            if (exception != null)
            {
                cancelOk.SetException(exception);
            }
            else
            {
                var reader      = new CustomBufferReader(arguments);
                var consumerTag = reader.ReadShortString();
                cancelOk.SetResult(consumerTag);
            }
        }
Example #4
0
        private void Handle_DeclareOk(object tcs, ReadOnlySequence <byte> arguments, Exception exception)
        {
            var declareOk = (TaskCompletionSource <DeclareResult>)tcs;

            if (exception != null)
            {
                declareOk.SetException(exception);
            }
            else
            {
                var reader = new CustomBufferReader(arguments);

                DeclareResult result;

                result.QueueName     = reader.ReadShortString();
                result.MessageCount  = reader.ReadUInt32();
                result.ConsumerCount = reader.ReadUInt32();

                declareOk.SetResult(result);
            }
        }