mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 21:36:17 +00:00
YESSSSS
typing works so basically it just stopped tryna read from the server once the server was silent for a sec so then i removed the return and made it an optional if let and wait 10_000 us if nothing comes back this is so goood changed it to get 256 bytes from server
This commit is contained in:
@@ -315,7 +315,7 @@ class SSHHandler: ObservableObject {
|
|||||||
guard ssh_channel_is_open(channel) != 0 else { return nil }
|
guard ssh_channel_is_open(channel) != 0 else { return nil }
|
||||||
guard ssh_channel_is_eof(channel) == 0 else { return nil }
|
guard ssh_channel_is_eof(channel) == 0 else { return nil }
|
||||||
|
|
||||||
var buffer: [CChar] = Array(repeating: 0, count: 16)
|
var buffer: [CChar] = Array(repeating: 0, count: 256)
|
||||||
let nbytes = ssh_channel_read_nonblocking(channel, &buffer, UInt32(buffer.count), 0)
|
let nbytes = ssh_channel_read_nonblocking(channel, &buffer, UInt32(buffer.count), 0)
|
||||||
|
|
||||||
guard nbytes > 0 else { return nil }
|
guard nbytes > 0 else { return nil }
|
||||||
@@ -350,6 +350,6 @@ class SSHHandler: ObservableObject {
|
|||||||
guard ssh_channel_is_eof(channel) == 0 else { return }
|
guard ssh_channel_is_eof(channel) == 0 else { return }
|
||||||
|
|
||||||
ssh_channel_change_pty_size(channel, Int32(toCols), Int32(toRows))
|
ssh_channel_change_pty_size(channel, Int32(toCols), Int32(toRows))
|
||||||
print("resized tty to \(toRows)rows and \(toCols)cols")
|
// print("resized tty to \(toRows)rows and \(toCols)cols")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,9 +26,12 @@ class SSHTerminalView: TerminalView, TerminalViewDelegate {
|
|||||||
guard let handler = self.handler else { return }
|
guard let handler = self.handler else { return }
|
||||||
while handler.connected {
|
while handler.connected {
|
||||||
guard let handler = self.handler else { break }
|
guard let handler = self.handler else { break }
|
||||||
guard let read = handler.readFromChannel() else { return }
|
if let read = handler.readFromChannel() {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.feed(text: read)
|
self.feed(text: read)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
usleep(10_000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,8 +54,10 @@ class SSHTerminalView: TerminalView, TerminalViewDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func send(source: TerminalView, data: ArraySlice<UInt8>) {
|
public func send(source: TerminalView, data: ArraySlice<UInt8>) {
|
||||||
let dataSlice = Data(bytes: [data.first], count: data.count)
|
let data = Data(data)
|
||||||
handler?.writeToChannel(String(data: dataSlice, encoding: .utf8))
|
// let dataSlice = Data(bytes: [data], count: data.count)
|
||||||
|
print("sending \(String(data: data, encoding: .utf8))")
|
||||||
|
handler?.writeToChannel(String(data: data, encoding: .utf8))
|
||||||
}
|
}
|
||||||
|
|
||||||
public func clipboardCopy(source: TerminalView, content: Data) {
|
public func clipboardCopy(source: TerminalView, content: Data) {
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ struct TerminalController: UIViewRepresentable {
|
|||||||
),
|
),
|
||||||
handler: handler
|
handler: handler
|
||||||
)
|
)
|
||||||
// tv.terminalDelegate = terminalDelegate
|
|
||||||
|
|
||||||
return tv
|
return tv
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user