using System;
using System.Threading;
using InABox.Clients;
using InABox.Core;

namespace InABox.Rpc
{
    public interface IRpcClientTransport : IRpcTransport
    {

        bool Ping();
        DatabaseInfo? Info();
        
        /// <summary>
        /// Connect to remote server.
        /// </summary>
        /// <param name="ct">Cancellation token to cancel the connection.</param>
        /// <returns><see langword="true"/> if connection success, <see langword="false"/> otherwise.</returns>
        bool Connect(CancellationToken ct = default);

        void Send(RpcMessage message);
        
        TResult Send<TCommand, TParameters, TResult>(TParameters parameters) 
            where TCommand : IRpcCommand<TParameters,TResult> 
            where TParameters : IRpcCommandParameters, ISerializeBinary
            where TResult : IRpcCommandResult, ISerializeBinary, new();
        
        void Disconnect();
        
        event RpcTransportMessageEvent OnMessage;

        bool IsConnected();
        bool IsSecure();
        string? ServerName();

    }
}