Skip to content

Commit 945bb7d

Browse files
committed
Create the closeConnection interface function
1 parent e246378 commit 945bb7d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// ObservableWebSocketClient+Connection.swift
3+
//
4+
//
5+
// Created by Fernando Fernandes on 18.04.24.
6+
//
7+
8+
import Foundation
9+
10+
public extension ObservableWebSocketClient {
11+
12+
/// Sends a close frame with an optional close reason.
13+
///
14+
/// - Parameter closeCode: A `URLSessionWebSocketTask.CloseCode`
15+
/// that indicates the reason for closing the connection. The default is `.normalClosure`.
16+
/// - Parameter reason: Optional further information to explain the closing.
17+
/// The value of this parameter is defined by the endpoints, not by the standard.
18+
func closeConnection(with closeCode: URLSessionWebSocketTask.CloseCode = .normalClosure,
19+
reason: String? = nil) {
20+
service.close(reason: reason)
21+
}
22+
}

0 commit comments

Comments
 (0)