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