Skip to content

Commit e246378

Browse files
committed
Create the service's close function
1 parent 377a910 commit e246378

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Sources/ObservableWebSocketClient/Network/ObservableWebSocketService.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ public extension ObservableWebSocketService {
4343
}
4444
}
4545
}
46+
47+
func close(with closeCode: URLSessionWebSocketTask.CloseCode = .normalClosure,
48+
reason: String? = nil) {
49+
webSocketTask?.cancel(with: closeCode, reason: reason?.data(using: .utf8))
50+
}
4651
}
4752

4853
// MARK: - Private

0 commit comments

Comments
 (0)