From 3a3ba6c34b3ae1fde8bc2a37439b324c3bb98a59 Mon Sep 17 00:00:00 2001 From: Igor Kim Date: Wed, 24 Mar 2021 10:42:23 +0100 Subject: [PATCH] Update README.md --- README.md | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f9d42a1..d8db9f1 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,62 @@ -# iperf-swift +# Swift wrapper for iPerf -A description of this package. +An appliction using this package: [iPerf SwiftUI](https://github.com/igorskh/iperf-swiftui) + +Package implements iPerf server and client. + +Usage example: +```swift +class IperfRunnerController: ObservableObject, Identifiable { + private var iperfRunner: IperfRunner? + + @Published var isDeleted = false + @Published var runnerState: IperfRunnerState = .ready + @Published var debugDescription: String = "" + @Published var displayError: Bool = false + @Published var results = [IperfIntervalResult]() { + didSet { + objectWillChange.send() + } + } + + func onResultReceived(result: IperfIntervalResult) { + if result.streams.count > 0 { + results.append(result) + } + } + + func onErrorReceived(error: IperfError) { + DispatchQueue.main.async { + self.displayError = error != .IENONE + self.debugDescription = error.debugDescription + } + } + + func onNewState(state: IperfRunnerState) { + if state != .unknown && state != runnerState { + DispatchQueue.main.async { + self.runnerState = state + } + } + } + + func start() { + self.formInput = formInput + + results = [] + debugDescription = "" + + iperfRunner = IperfRunner(with: IperfConfiguration()) + iperfRunner!.start( + onResultReceived, + onErrorReceived, + onNewState + ) + } + + func stop() { + iperfRunner!.stop() + } +} + +```