Socket logic force disconnect/reconnect when server doesn't properly close it

This commit is contained in:
maddiebaka
2023-06-27 18:41:22 -04:00
parent 90be4321b0
commit e440f3489b
5 changed files with 105 additions and 25 deletions

View File

@@ -13,6 +13,8 @@ struct PrinterConfigView: View {
@ObservedObject var printerManager: MoonrakerSocketManager
@ObservedObject var bonjourBrowser = BonjourBrowser()
//@State var bonjourBrowser = NWBrowser(for: .bonjourWithTXTRecord(type: "_moonraker._tcp", domain: "local."), using: .tcp)
@Environment(\.openURL) private var openURL
@@ -61,7 +63,7 @@ struct PrinterConfigView: View {
}.buttonStyle(PlainButtonStyle())
}
ForEach(bonjourBrowser.NDEngineResults , id: \.hashValue) { result in
ForEach(bonjourBrowser.networkResults, id: \.hashValue) { result in
HStack {
Text(result.endpoint.toFriendlyString())
Button {
@@ -79,6 +81,10 @@ struct PrinterConfigView: View {
}
.onAppear {
NSApplication.shared.activate(ignoringOtherApps: true)
bonjourBrowser.enableScan(DispatchQueue.main)
}
.onDisappear {
bonjourBrowser.disableScan()
}
}
}

View File

@@ -86,13 +86,6 @@ struct SoyuzMenuBarExtraView: View {
Text("Printers")
.foregroundColor(Color("ButtonForegroundColor"))
}
/* Debugging Stuff */
Button {
notification.sendNotification(.printComplete)
} label: {
Text("Notify")
}
/* Debugging Stuff */
Spacer()
if(printerManager.isConnected) {
Image(systemName: "network")