From 5e6c77c64d0516c33ceba4fb4f597b17ed2ae7e5 Mon Sep 17 00:00:00 2001 From: Sebastian Lenzlinger <74497638+sebaschi@users.noreply.github.com> Date: Thu, 13 Jul 2023 17:18:10 +0200 Subject: [PATCH] Add Button to send WANT_msg vector (Implementation Ongoing) --- RippleChat/DataStore.swift | 6 +++++- RippleChat/Views/PeeringView.swift | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) 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]() + +}