diff --git a/RippleChat/DataStore.swift b/RippleChat/DataStore.swift index 8154909..309020c 100644 --- a/RippleChat/DataStore.swift +++ b/RippleChat/DataStore.swift @@ -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] diff --git a/RippleChat/Views/PeeringView.swift b/RippleChat/Views/PeeringView.swift index 96a1ef9..8319f88 100644 --- a/RippleChat/Views/PeeringView.swift +++ b/RippleChat/Views/PeeringView.swift @@ -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]() + +}