using System;
using System.Threading.Tasks;
// ReSharper disable UnusedMember.Global
namespace Tapeti
{
///
/// Contains information about the reason for a lost connection.
///
public class DisconnectedEventArgs
{
///
/// The ReplyCode as indicated by the client library
///
public ushort ReplyCode;
///
/// The ReplyText as indicated by the client library
///
public string ReplyText;
}
///
public delegate void DisconnectedEventHandler(object sender, DisconnectedEventArgs e);
///
///
/// Represents a connection to a RabbitMQ server
///
public interface IConnection : IDisposable
{
///
/// Creates a subscriber to consume messages from the bound queues.
///
/// If true, the subscriber will start consuming messages immediately. If false, the queues will be
/// declared but no messages will be consumed yet. Call Resume on the returned ISubscriber to start consuming messages.
Task Subscribe(bool startConsuming = true);
///
/// Synchronous version of Subscribe.
///
/// If true, the subscriber will start consuming messages immediately. If false, the queues will be
/// declared but no messages will be consumed yet. Call Resume on the returned ISubscriber to start consuming messages.
ISubscriber SubscribeSync(bool startConsuming = true);
///
/// Returns an IPublisher implementation for the current connection.
///
///
IPublisher GetPublisher();
///
/// Closes the connection to RabbitMQ.
///
Task Close();
///
/// Fired when a connection to RabbitMQ has been established.
///
event EventHandler Connected;
///
/// Fired when the connection to RabbitMQ has been lost.
///
event DisconnectedEventHandler Disconnected;
///
/// Fired when the connection to RabbitMQ has been recovered after an unexpected disconnect.
///
event EventHandler Reconnected;
}
}