|
|
|
|
@ -26,13 +26,12 @@ public abstract partial class TerminalViewModel : ObservableObject, ITerminalVie |
|
|
|
|
// register event handler for connection request from viewmodel |
|
|
|
|
if(value != null) |
|
|
|
|
{ |
|
|
|
|
protocolSettings!.ConnectRequested += OnViewModelRequestedConnect; ; |
|
|
|
|
protocolSettings!.ConnectRequested += OnViewModelRequestedConnect; ; ; |
|
|
|
|
protocolSettings!.DisconnectRequested += OnViewModelRequestedDisconnect; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Method to override if any closing actions are required. |
|
|
|
|
/// Closing can be cancelled using the return value. |
|
|
|
|
@ -49,13 +48,19 @@ public abstract partial class TerminalViewModel : ObservableObject, ITerminalVie |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void OnViewModelRequestedConnect(object? sender, IProtocolSettings e) |
|
|
|
|
private void OnViewModelRequestedConnect(object? sender, ConnectionRequestEventArgs e) |
|
|
|
|
{ |
|
|
|
|
this.CommunicationProtocol?.Connect(e); |
|
|
|
|
// guard uninitialized CommunicationProtocol |
|
|
|
|
if (CommunicationProtocol == null) { throw new Exception($"To call '{nameof(OnViewModelRequestedConnect)}()', CommunicationProtocol must not be null!"); } |
|
|
|
|
|
|
|
|
|
e.Success = this.CommunicationProtocol.Connect(e.Settings); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void OnViewModelRequestedDisconnect(object? sender, EventArgs e) |
|
|
|
|
{ |
|
|
|
|
this.CommunicationProtocol?.Disconnect(); |
|
|
|
|
// guard uninitialized CommunicationProtocol |
|
|
|
|
if (CommunicationProtocol == null) { throw new Exception($"To call '{nameof(OnViewModelRequestedConnect)}()', CommunicationProtocol must not be null!"); } |
|
|
|
|
|
|
|
|
|
this.CommunicationProtocol.Disconnect(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|