mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
Dispose of old connection, if present.
This commit is contained in:
parent
7e6476ed73
commit
2390b67201
@ -47,13 +47,18 @@ namespace Remotely.ScreenCast.Core.Sockets
|
||||
|
||||
public async Task Connect(string host)
|
||||
{
|
||||
if (Connection != null)
|
||||
{
|
||||
await Connection.StopAsync();
|
||||
await Connection.DisposeAsync();
|
||||
}
|
||||
Connection = new HubConnectionBuilder()
|
||||
.WithUrl($"{host}/RCDeviceHub")
|
||||
.AddMessagePackProtocol()
|
||||
.Build();
|
||||
|
||||
ApplyConnectionHandlers();
|
||||
|
||||
|
||||
await Connection.StartAsync();
|
||||
}
|
||||
|
||||
@ -134,7 +139,6 @@ namespace Remotely.ScreenCast.Core.Sockets
|
||||
Connection.Closed += (ex) =>
|
||||
{
|
||||
Logger.Write($"Connection closed. Error: {ex?.Message}");
|
||||
Environment.Exit(0);
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user