mirror of
https://gitlab.com/fabinfra/fabaccess/borepin.git
synced 2025-06-11 19:13:23 +02:00
Added: New API Class
This commit is contained in:
@ -13,6 +13,7 @@ using FabAccessAPI.Exceptions;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Net.Security;
|
||||
using System.Security.Authentication;
|
||||
using FabAccessAPI;
|
||||
|
||||
namespace Borepin.Service.BFFH
|
||||
{
|
||||
@ -22,7 +23,6 @@ namespace Borepin.Service.BFFH
|
||||
private readonly ConnectionStorage _ConnectionStorage;
|
||||
private readonly ConnectionCredentialStorage _ConnectionCredentialStorage;
|
||||
|
||||
private FabAccessAPI.Connection _APIConnection;
|
||||
private Connection_Plain _CurrentConnection;
|
||||
#endregion
|
||||
|
||||
@ -37,31 +37,9 @@ namespace Borepin.Service.BFFH
|
||||
#region Fields
|
||||
|
||||
/// <summary>
|
||||
/// Current Connection of Service
|
||||
/// API Connection
|
||||
/// </summary>
|
||||
public Connection CurrentConnection
|
||||
{
|
||||
get
|
||||
{
|
||||
return _CurrentConnection;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if Service is connected to a Server
|
||||
/// </summary>
|
||||
public bool IsConnected
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_APIConnection != null && _APIConnection.RpcClient != null)
|
||||
{
|
||||
return _APIConnection.RpcClient.State == Capnp.Rpc.ConnectionState.Active;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public API API { get; private set; }
|
||||
#endregion
|
||||
|
||||
#region Method
|
||||
@ -78,7 +56,7 @@ namespace Borepin.Service.BFFH
|
||||
/// </summary>
|
||||
public async Task RemoveConnection(Connection connection)
|
||||
{
|
||||
if (IsConnected && connection.Equals(CurrentConnection))
|
||||
if (API != null && API.IsConnected && connection.Equals(_CurrentConnection))
|
||||
{
|
||||
await Disconnect().ConfigureAwait(false);
|
||||
}
|
||||
@ -109,7 +87,6 @@ namespace Borepin.Service.BFFH
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
TcpRpcClient rpcClient = await _ConnectAsync(connection.Address.Host, connection.Address.Port).ConfigureAwait(false);
|
||||
rpcClient.Dispose();
|
||||
|
||||
@ -176,7 +153,6 @@ namespace Borepin.Service.BFFH
|
||||
/// <exception cref="AuthenticatingFailedException"></exception>
|
||||
public async Task Connect(Connection connection, string password)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
TcpRpcClient rpcClient = await _ConnectAsync(connection.Address.Host, connection.Address.Port).ConfigureAwait(false);
|
||||
@ -229,6 +205,10 @@ namespace Borepin.Service.BFFH
|
||||
|
||||
_APIConnection = new FabAccessAPI.Connection(rpcClient);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Reference in New Issue
Block a user