Skip to content

Commit 362aec4

Browse files
committed
Instantly remove sockets when not listening
1 parent 199bca4 commit 362aec4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Sources/sACNKit/Source/sACNSource.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ final public class sACNSource {
322322
if existingInterfaces.isEmpty {
323323
// not possible for IPv6
324324

325-
if universes.isEmpty {
325+
if universes.isEmpty || !_isListening {
326326
// deinit first stops listening
327327
sockets.removeAll()
328328
} else {
@@ -350,7 +350,7 @@ final public class sACNSource {
350350
} else if newInterfaces.isEmpty {
351351
// not possible for IPv6
352352

353-
if universes.isEmpty {
353+
if universes.isEmpty || !_isListening {
354354
// deinit first stops listening
355355
sockets.removeAll()
356356
} else {
@@ -380,7 +380,7 @@ final public class sACNSource {
380380
// terminate all universes on sockets no longer needed, removing the sockets but not the universes
381381
let socketsToRemove = sockets.filter { interfacesToRemove.contains($0.key) }
382382
if !socketsToRemove.isEmpty {
383-
if universes.isEmpty {
383+
if universes.isEmpty || !_isListening {
384384
for socketToRemove in socketsToRemove.keys {
385385
// deinit first stops listening
386386
sockets.removeValue(forKey: socketToRemove)

0 commit comments

Comments
 (0)