Skip to content

Commit 221d067

Browse files
committed
Addes error state to SocketControllerViewDelegate
1 parent 1ba66f6 commit 221d067

File tree

4 files changed

+19
-20
lines changed

4 files changed

+19
-20
lines changed

iPhoneMoCap.xcodeproj/project.pbxproj

+2-10
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@
7272
AEC6BF3D1EAF320E007CA6E5 /* iPhoneMoCap */ = {
7373
isa = PBXGroup;
7474
children = (
75-
F6DFBA871FB0590000AF04FD /* ARKit */,
75+
F6DFBA751FB058B300AF04FD /* FaceGeoViewController.swift */,
76+
F6DFBA731FB058B300AF04FD /* BlendShapeTracker.swift */,
7677
AEFC972D1EB9A4EC0003E407 /* SocketController.swift */,
7778
AEC6BF3E1EAF320E007CA6E5 /* AppDelegate.swift */,
7879
AEC6BF451EAF320E007CA6E5 /* Assets.xcassets */,
@@ -90,15 +91,6 @@
9091
name = Frameworks;
9192
sourceTree = "<group>";
9293
};
93-
F6DFBA871FB0590000AF04FD /* ARKit */ = {
94-
isa = PBXGroup;
95-
children = (
96-
F6DFBA751FB058B300AF04FD /* FaceGeoViewController.swift */,
97-
F6DFBA731FB058B300AF04FD /* BlendShapeTracker.swift */,
98-
);
99-
path = ARKit;
100-
sourceTree = "<group>";
101-
};
10294
/* End PBXGroup section */
10395

10496
/* Begin PBXNativeTarget section */
File renamed without changes.

iPhoneMoCap/ARKit/FaceGeoViewController.swift iPhoneMoCap/FaceGeoViewController.swift

+5
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ class FaceGeoViewController: UIViewController, ARSessionDelegate, SocketControll
141141
loadingBanner?.autoDismiss = false
142142
loadingBanner?.show()
143143
break
144+
145+
146+
case .error(let message):
147+
NotificationBanner(title: "Uh Oh!", subtitle: message, style: .danger).show()
148+
break
144149
}
145150
}
146151

iPhoneMoCap/SocketController.swift

+12-10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ protocol SocketControllerViewDelegate: class {
99
enum SocketControllerState {
1010
case waitingForHost
1111
case readyToReceive
12+
case error(message: String)
1213
}
1314

1415
class SocketController: NSObject, StreamDelegate, GCDAsyncUdpSocketDelegate {
@@ -25,14 +26,24 @@ class SocketController: NSObject, StreamDelegate, GCDAsyncUdpSocketDelegate {
2526
broadCastListnerSocket = GCDAsyncUdpSocket(delegate: self, delegateQueue: DispatchQueue.main)
2627
}
2728

29+
30+
func closeSockets() {
31+
outputSocket?.close()
32+
broadCastListnerSocket?.close()
33+
}
34+
35+
func openSockets() {
36+
setupAutoDiscoveryListner();
37+
}
38+
2839
func setupAutoDiscoveryListner(){
2940

3041
do {
3142
try broadCastListnerSocket?.bind(toPort: 49452)
3243
try broadCastListnerSocket?.beginReceiving()
3344

3445
} catch {
35-
NotificationBanner(title: "Uhh Oh!", subtitle: "There was a problem enabling Auto Discovery", style: .danger).show()
46+
self.delegate?.updatedState(state: .error(message: "There was a problem enabling Auto Discovery"))
3647
print(error)
3748
}
3849

@@ -47,15 +58,6 @@ class SocketController: NSObject, StreamDelegate, GCDAsyncUdpSocketDelegate {
4758
let data = message.data(using: .ascii)!
4859
outputSocket?.send(data, toHost: hostAddress!, port: 49452, withTimeout: 0.1, tag: 0)
4960
}
50-
51-
func closeSockets() {
52-
outputSocket?.close()
53-
broadCastListnerSocket?.close()
54-
}
55-
56-
func openSockets() {
57-
setupAutoDiscoveryListner();
58-
}
5961

6062
func udpSocket(_ sock: GCDAsyncUdpSocket, didReceive data: Data, fromAddress address: Data, withFilterContext filterContext: Any?) {
6163
let message = String(data: data, encoding: String.Encoding.ascii)

0 commit comments

Comments
 (0)