Add Button to send WANT_msg vector (Implementation Ongoing)
This commit is contained in:
parent
d2b578dbad
commit
5e6c77c64d
@ -10,9 +10,13 @@ import Foundation
|
|||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
class DataStore: ObservableObject {
|
class DataStore: ObservableObject {
|
||||||
|
|
||||||
|
typealias FID = String
|
||||||
|
typealias SEQ = Int
|
||||||
|
|
||||||
@Published var personalID: String
|
@Published var personalID: String
|
||||||
@Published var personalFeed: Feed
|
@Published var personalFeed: Feed
|
||||||
@Published var friends: [String:Int]
|
@Published var friends: [FID:SEQ]
|
||||||
@Published var feedStores: [FeedStore]
|
@Published var feedStores: [FeedStore]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,20 @@ struct PeeringView: View {
|
|||||||
}
|
}
|
||||||
.navigationTitle("Peering")
|
.navigationTitle("Peering")
|
||||||
.navigationViewStyle(StackNavigationViewStyle())
|
.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())
|
.environmentObject(BluetoothController())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct WantMessage: Codable {
|
||||||
|
var commmand = "WANT"
|
||||||
|
var friends = [String:Int]()
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user