Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
igorskh authored Mar 24, 2021
1 parent 898b64a commit 3a3ba6c
Showing 1 changed file with 61 additions and 2 deletions.
63 changes: 61 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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()
}
}

```

0 comments on commit 3a3ba6c

Please sign in to comment.