mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
fix crash when disconnecting, fix close terminal on exit
This commit is contained in:
@@ -17,7 +17,7 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
|
||||
@Published var title: String = ""
|
||||
@Published var state: SSHState = .idle
|
||||
var connected: Bool {
|
||||
return checkConnected(state)
|
||||
return ssh_channel_is_open(channel) == 1 && checkConnected(state)
|
||||
}
|
||||
|
||||
@Published var testSuceeded: Bool? = nil
|
||||
@@ -46,7 +46,6 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
|
||||
|
||||
func go() {
|
||||
guard !connected else {
|
||||
withAnimation { state = .idle }
|
||||
disconnect()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -28,19 +28,16 @@ final class SSHTerminalView: TerminalView, Sendable, @preconcurrency TerminalVie
|
||||
sshQueue.async {
|
||||
Task {
|
||||
guard let handler = await self.handler else { return }
|
||||
|
||||
while handler.connected {
|
||||
if let read = handler.readFromChannel() {
|
||||
// Task { [weak self] in
|
||||
// guard let self else { return }
|
||||
Task { @MainActor in
|
||||
self.feed(text: read)
|
||||
}
|
||||
// }
|
||||
} else {
|
||||
try? await Task.sleep(nanoseconds: 10_000_000) //10ms
|
||||
Task {try? await Task.sleep(nanoseconds: 10_000_000) } //10ms
|
||||
}
|
||||
}
|
||||
handler.disconnect()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user