mirror of
https://gitlab.com/fabinfra/fabaccess/borepin.git
synced 2025-04-20 18:36:31 +02:00
Fixed Create new Connection while Connected
This commit is contained in:
parent
ec482af4bc
commit
aab362b2c0
@ -64,8 +64,14 @@ namespace Borepin.PageModel.AddServerProcess
|
|||||||
Address = builder.Uri
|
Address = builder.Uri
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if(_BFFHService.ActiveConnection != null)
|
||||||
|
{
|
||||||
|
await _BFFHService.Disconnect();
|
||||||
|
}
|
||||||
await _BFFHService.Connect(connection);
|
await _BFFHService.Connect(connection);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
INavigationResult result = await _NavigationService.NavigateAsync("AddServerProcess_LoginChoosePage");
|
INavigationResult result = await _NavigationService.NavigateAsync("AddServerProcess_LoginChoosePage");
|
||||||
if(!result.Success)
|
if(!result.Success)
|
||||||
{
|
{
|
||||||
|
@ -71,7 +71,7 @@ namespace Borepin.PageModel
|
|||||||
|
|
||||||
if(IsConnected)
|
if(IsConnected)
|
||||||
{
|
{
|
||||||
_BFFHService.Disconnect();
|
await _BFFHService.Disconnect();
|
||||||
|
|
||||||
IsConnected = false;
|
IsConnected = false;
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ namespace Borepin.PageModel
|
|||||||
|
|
||||||
if(_BFFHService.ActiveConnection != null && connection == _BFFHService.ActiveConnection)
|
if(_BFFHService.ActiveConnection != null && connection == _BFFHService.ActiveConnection)
|
||||||
{
|
{
|
||||||
_BFFHService.Disconnect();
|
await _BFFHService.Disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
await _ConnectionService.RemoveConnection(connection);
|
await _ConnectionService.RemoveConnection(connection);
|
||||||
|
@ -1,13 +1,27 @@
|
|||||||
using Borepin.Model;
|
using Borepin.Model;
|
||||||
using Borepin.Service.Credentials;
|
using Borepin.Service.Credentials;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Capnp.Rpc;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using FabAccessAPI.Schema;
|
using FabAccessAPI.Schema;
|
||||||
using System.Net.Http;
|
using System;
|
||||||
|
|
||||||
namespace Borepin.Service.BFFH
|
namespace Borepin.Service.BFFH
|
||||||
{
|
{
|
||||||
|
public class ConnectionActiveException : Exception
|
||||||
|
{
|
||||||
|
public ConnectionActiveException()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConnectionActiveException(string message) : base(message)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConnectionActiveException(string message, Exception inner) : base(message, inner)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class BFFHService : IBFFHService
|
public class BFFHService : IBFFHService
|
||||||
{
|
{
|
||||||
private readonly ICredentialService _CredentialService;
|
private readonly ICredentialService _CredentialService;
|
||||||
@ -27,10 +41,10 @@ namespace Borepin.Service.BFFH
|
|||||||
{
|
{
|
||||||
if (_Connection != null || ActiveConnection != null)
|
if (_Connection != null || ActiveConnection != null)
|
||||||
{
|
{
|
||||||
throw new System.Exception("Still connected");
|
throw new ConnectionActiveException();
|
||||||
}
|
}
|
||||||
|
|
||||||
TcpRpcClient rpcClient = new TcpRpcClient();
|
Capnp.Rpc.TcpRpcClient rpcClient = new Capnp.Rpc.TcpRpcClient();
|
||||||
|
|
||||||
rpcClient.Connect(connection.Address.Host, connection.Address.Port);
|
rpcClient.Connect(connection.Address.Host, connection.Address.Port);
|
||||||
|
|
||||||
@ -43,11 +57,13 @@ namespace Borepin.Service.BFFH
|
|||||||
ActiveConnection = connection;
|
ActiveConnection = connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Disconnect()
|
public async Task Disconnect()
|
||||||
{
|
{
|
||||||
_Connection.RpcClient?.Dispose();
|
_Connection.RpcClient?.Dispose();
|
||||||
_Connection = null;
|
_Connection = null;
|
||||||
ActiveConnection = null;
|
ActiveConnection = null;
|
||||||
|
|
||||||
|
await Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanAuthenticate()
|
public bool CanAuthenticate()
|
||||||
|
@ -31,7 +31,7 @@ namespace Borepin.Service.BFFH
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Disconnect from BFFH Instance
|
/// Disconnect from BFFH Instance
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void Disconnect();
|
Task Disconnect();
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user