Skip to content

Instantly share code, notes, and snippets.

@fakiho
Created February 27, 2021 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fakiho/6a0d1577a99c6f36a1d4e19a6762593b to your computer and use it in GitHub Desktop.
Save fakiho/6a0d1577a99c6f36a1d4e19a6762593b to your computer and use it in GitHub Desktop.
import Foundation
public enum NetworkVPNStatus: String {
case invalid = "Press to allow VPN"
case disconnected = "Tap to Connect"
case connecting = "Connecting"
case connected = "Tap to disconnect"
case reasserting = "Reasserting"
case disconnecting = "Disconnecting"
}
protocol NetworkVPNUseCase {
func connect(configuration: VPNAccount)
func getStatus(completion: @escaping (NetworkVPNStatus) -> ())
func disconnect()
func loadVPNConfig(completion: @escaping () -> Void)
func getServers(completion: @escaping (Result<[Server], Error>) -> Void) -> Cancellable?
}
final class DefaultNetworkVPNUseCase: NetworkVPNUseCase {
private(set) var vpnManager: DVPNRepository
init(vpnManager: DVPNRepository) {
self.vpnManager = vpnManager
}
func connect(configuration: VPNAccount) {
vpnManager.connect(configuration: configuration)
}
func getStatus(completion: @escaping (NetworkVPNStatus) -> ()) {
}
func disconnect() {
vpnManager.disconnect()
}
func loadVPNConfig(completion: @escaping () -> Void) {
self.vpnManager.loadVPNConfig(completion: completion)
}
func getServers(completion: @escaping (Result<[Server], Error>) -> Void) -> Cancellable? {
return self.vpnManager.getServers(completion: completion)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment