-
Notifications
You must be signed in to change notification settings - Fork 4
/
AppDelegate.swift
49 lines (37 loc) · 1.34 KB
/
AppDelegate.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// AppDelegate.swift
// ServusExample
//
// Created by Alexander Juda on 28/12/15.
// Copyright © 2015 Alexander Juda. All rights reserved.
//
import UIKit
import Servus
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var explorer: Explorer!
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
explorer = Explorer()
explorer.delegate = self
explorer.startExploring()
print("Started exploring nearby peers...")
window = UIWindow(frame: UIScreen.main.bounds)
let vc = UIViewController()
vc.view.backgroundColor = UIColor.white
window?.rootViewController = vc
window?.makeKeyAndVisible()
return true
}
}
extension AppDelegate: ExplorerDelegate {
func explorer(_ explorer: Explorer, didSpotPeer peer: Peer) {
print("Spotted \(peer.identifier). Didn't determine its addresses yet")
}
func explorer(_ explorer: Explorer, didDeterminePeer peer: Peer) {
print("Determined hostname for \(peer.identifier): \(peer.hostname!)")
}
func explorer(_ explorer: Explorer, didLosePeer peer: Peer) {
print("Lost \(peer.hostname) from sight")
}
}