Skip to content

Commit d2a32e4

Browse files
committed
Add main thread checks to server start / stop calls
1 parent d6d2d3e commit d2a32e4

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

AirMessage/Connection/Connect/DataProxyConnect.swift

+4
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class DataProxyConnect: DataProxy {
5252
}
5353

5454
func startServer() {
55+
assertDispatchQueue(DispatchQueue.main)
56+
5557
//Ignore if we're already connecting or connected
5658
guard !isActive else { return }
5759

@@ -89,6 +91,8 @@ class DataProxyConnect: DataProxy {
8991
}
9092

9193
func stopServer() {
94+
assertDispatchQueue(DispatchQueue.main)
95+
9296
//Ignore if we're not running
9397
guard isActive else { return }
9498

AirMessage/Connection/Direct/DataProxyTCP.swift

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class DataProxyTCP: DataProxy {
3131
}
3232

3333
func startServer() {
34+
assertDispatchQueue(DispatchQueue.main)
35+
3436
//Ignore if the server is already running
3537
guard !serverRunning else { return }
3638

@@ -171,6 +173,8 @@ class DataProxyTCP: DataProxy {
171173
}
172174

173175
func stopServer() {
176+
assertDispatchQueue(DispatchQueue.main)
177+
174178
//Ignore if the server isn't running
175179
guard serverRunning else { return }
176180
serverRunning = false

0 commit comments

Comments
 (0)