private static async Task receive(Stream stream, IReceiverCallback callback, Envelope[] messages, Uri uri) { var status = callback.Received(uri, messages); switch (status) { case ReceivedStatus.ProcessFailure: await stream.SendBuffer(Constants.ProcessingFailureBuffer); break; case ReceivedStatus.QueueDoesNotExist: await stream.SendBuffer(Constants.QueueDoesNotExistBuffer); break; default: await stream.SendBuffer(Constants.ReceivedBuffer); var ack = await stream.ReadExpectedBuffer(Constants.AcknowledgedBuffer); if (ack) { callback.Acknowledged(messages); } else { callback.NotAcknowledged(messages); } break; } }
private static async Task receive(Stream stream, IReceiverCallback callback, Envelope[] messages, Uri uri) { // Just a ping if (messages.Any() && messages.First().IsPing()) { await stream.SendBuffer(ReceivedBuffer); // We aren't gonna use this in this case var ack = await stream.ReadExpectedBuffer(AcknowledgedBuffer); return; } var status = await callback.Received(uri, messages); switch (status) { case ReceivedStatus.ProcessFailure: await stream.SendBuffer(ProcessingFailureBuffer); break; case ReceivedStatus.QueueDoesNotExist: await stream.SendBuffer(QueueDoesNotExistBuffer); break; default: await stream.SendBuffer(ReceivedBuffer); var ack = await stream.ReadExpectedBuffer(AcknowledgedBuffer); if (ack) { await callback.Acknowledged(messages); } else { await callback.NotAcknowledged(messages); } break; } }