aboutsummaryrefslogtreecommitdiff
path: root/Hotline/Models
diff options
context:
space:
mode:
authorDustin Mierau <dustin@mierau.me>2024-01-12 09:50:18 -0800
committerDustin Mierau <dustin@mierau.me>2024-01-12 09:50:18 -0800
commit2f210991684c87073dd7534d2d0416d91cf50275 (patch)
tree03dc2edb225ab583fbc286de37f927194377a085 /Hotline/Models
parent768bc9136c91b5dc31eef96088e7d1796243d81b (diff)
Experimenting with a simpler stream/delegate bsaed socket library for Tracker listing for now. Added consume methods to Data and [UInt8] arrays to make reading bytes off the wire easier to read..
Diffstat (limited to 'Hotline/Models')
-rw-r--r--Hotline/Models/Hotline.swift12
1 files changed, 6 insertions, 6 deletions
diff --git a/Hotline/Models/Hotline.swift b/Hotline/Models/Hotline.swift
index e62ac15..445d09e 100644
--- a/Hotline/Models/Hotline.swift
+++ b/Hotline/Models/Hotline.swift
@@ -223,13 +223,13 @@ final class Hotline: HotlineClientDelegate, HotlineFileClientDelegate {
// MARK: -
@MainActor func getServerList(tracker: String, port: Int = HotlinePorts.DefaultTrackerPort) async -> [Server] {
- let fetchedServers: [HotlineServer] = await self.trackerClient.fetchServers(address: tracker, port: port)
-
var servers: [Server] = []
- for s in fetchedServers {
- if let serverName = s.name {
- servers.append(Server(name: serverName, description: s.description, address: s.address, port: Int(s.port), users: Int(s.users)))
+ if let fetchedServers: [HotlineServer] = try? await self.trackerClient.fetchServers(address: tracker, port: port) {
+ for s in fetchedServers {
+ if let serverName = s.name {
+ servers.append(Server(name: serverName, description: s.description, address: s.address, port: Int(s.port), users: Int(s.users)))
+ }
}
}
@@ -237,7 +237,7 @@ final class Hotline: HotlineClientDelegate, HotlineFileClientDelegate {
}
@MainActor func disconnectTracker() {
- self.trackerClient.disconnect()
+ self.trackerClient.close()
}
@MainActor func login(server: Server, username: String, iconID: Int, callback: ((Bool) -> Void)? = nil) {