Add Button to send WANT_msg vector (Implementation Ongoing)

This commit is contained in:
Sebastian Lenzlinger 2023-07-13 17:18:10 +02:00
parent d2b578dbad
commit 5e6c77c64d
2 changed files with 25 additions and 1 deletions

View File

@ -10,9 +10,13 @@ import Foundation
@MainActor
class DataStore: ObservableObject {
typealias FID = String
typealias SEQ = Int
@Published var personalID: String
@Published var personalFeed: Feed
@Published var friends: [String:Int]
@Published var friends: [FID:SEQ]
@Published var feedStores: [FeedStore]

View File

@ -19,6 +19,20 @@ struct PeeringView: View {
}
.navigationTitle("Peering")
.navigationViewStyle(StackNavigationViewStyle())
Button(action: {
do {
let WANT_msg = WantMessage(friends: dataStore.friends)
let encoded_msg = try JSONEncoder().encode(WANT_msg)
} catch {
fatalError(error.localizedDescription)
}
}) {
}
.padding()
}
}
}
@ -30,3 +44,9 @@ struct PeeringView_Previews: PreviewProvider {
.environmentObject(BluetoothController())
}
}
struct WantMessage: Codable {
var commmand = "WANT"
var friends = [String:Int]()
}