tokenary/Encrypted Ink/Agent.swift
2021-06-12 20:37:56 +03:00

34 lines
791 B
Swift

// Copyright © 2021 Encrypted Ink. All rights reserved.
import Cocoa
class Agent {
private var connectivity: NearbyConnectivity!
func start() {
connectivity = NearbyConnectivity(delegate: self)
}
}
func showScreen() { // TODO: make private
NSApplication.shared.windows.forEach { $0.close() }
let storyboard = NSStoryboard(name: "Main", bundle: nil)
let windowController = storyboard.instantiateInitialController() as? NSWindowController
windowController?.showWindow(nil)
NSApp.activate(ignoringOtherApps: true)
windowController?.window?.makeKeyAndOrderFront(nil)
}
extension Agent: NearbyConnectivityDelegate {
func didFind(link: String) {
globalLink = link
showScreen()
}
}
var globalLink = ""