Fix missing async in Demo

This commit is contained in:
Davide De Rosa 2022-04-12 20:47:58 +02:00
parent 6e7eab421e
commit 7b72114893
3 changed files with 43 additions and 27 deletions

View File

@ -80,7 +80,9 @@ class OpenVPNViewController: UIViewController {
object: nil
)
vpn.prepare()
Task {
await vpn.prepare()
}
// testFetchRef()
}
@ -123,14 +125,16 @@ class OpenVPNViewController: UIViewController {
return
}
var extra = NetworkExtensionExtra()
extra.passwordReference = passwordReference
vpn.reconnect(
tunnelIdentifier,
configuration: cfg!,
extra: extra,
after: .seconds(2)
)
Task {
var extra = NetworkExtensionExtra()
extra.passwordReference = passwordReference
try await vpn.reconnect(
tunnelIdentifier,
configuration: cfg!,
extra: extra,
after: .seconds(2)
)
}
}
func disconnect() {

View File

@ -75,7 +75,9 @@ class OpenVPNViewController: NSViewController {
object: nil
)
vpn.prepare()
Task {
await vpn.prepare()
}
// testFetchRef()
}
@ -114,18 +116,22 @@ class OpenVPNViewController: NSViewController {
return
}
var extra = NetworkExtensionExtra()
extra.passwordReference = passwordReference
vpn.reconnect(
tunnelIdentifier,
configuration: cfg!,
extra: extra,
after: .seconds(2)
)
Task {
var extra = NetworkExtensionExtra()
extra.passwordReference = passwordReference
try await vpn.reconnect(
tunnelIdentifier,
configuration: cfg!,
extra: extra,
after: .seconds(2)
)
}
}
func disconnect() {
vpn.disconnect()
Task {
await vpn.disconnect()
}
}
func updateButton() {

View File

@ -72,7 +72,9 @@ class WireGuardViewController: NSViewController {
object: nil
)
vpn.prepare()
Task {
await vpn.prepare()
}
}
@IBAction func connectionClicked(_ sender: Any) {
@ -105,16 +107,20 @@ class WireGuardViewController: NSViewController {
return
}
vpn.reconnect(
tunnelIdentifier,
configuration: cfg,
extra: nil,
after: .seconds(2)
)
Task {
try await vpn.reconnect(
tunnelIdentifier,
configuration: cfg,
extra: nil,
after: .seconds(2)
)
}
}
func disconnect() {
vpn.disconnect()
Task {
await vpn.disconnect()
}
}
func updateButton() {