using Capnp.Rpc;
using FabAccessAPI.Schema;
using System;
using System.Threading.Tasks;

namespace FabAccessAPI
{
    public interface IAPI
    {
        /// <summary>
        /// Data to establish connection.
        /// </summary>
        /// Without SecretProperties
        ConnectionData ConnectionData { get; }

        /// <summary>
        /// Information about the established connection.
        /// </summary>
        ConnectionInfo ConnectionInfo { get; }

        /// <summary>
        /// Is API connected?
        /// </summary>
        bool IsConnected { get; }

        /// <summary>
        /// Get session when connection is established
        /// </summary>
        Session Session { get; }

        /// <summary>
        /// Event on changes in connection state.
        /// </summary>
        event EventHandler<ConnectionStatusChange> ConnectionStatusChanged;

        /// <summary>
        /// Unbind all Events from ConnectionStatus Change
        /// </summary>
        void UnbindAllEvents();

        /// <summary>
        /// Connect to BFFH Server
        /// </summary>
        /// <param name="connectionData"></param>
        Task Connect(ConnectionData connectionData, TcpRpcClient tcpRpcClient = null);

        /// <summary>
        /// Disconnect from BFFH Server
        /// </summary>
        Task Disconnect();

        /// <summary>
        /// Reconnect after connection loss with the last ConnectionData
        /// </summary>
        Task Reconnect();

        /// <summary>
        /// Connect to Server and get ConnectionInfo.
        /// The Connection is not maintained.
        /// </summary>
        Task<ConnectionInfo> TestConnection(ConnectionData connectionData, TcpRpcClient tcpRpcClient = null);
    }
}
