File tree Expand file tree Collapse file tree 1 file changed +10
-13
lines changed
Sources/BluetoothLinux/L2CAP Expand file tree Collapse file tree 1 file changed +10
-13
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,16 @@ public final class L2CAPSocket: Bluetooth.L2CAPSocket {
2525 /// L2CAP Socket address
2626 public let address : BluetoothAddress
2727
28+ public lazy var event : L2CAPSocketEventStream = { [ unowned self] in
29+ let stream = self . socket. event
30+ var iterator = stream. makeAsyncIterator ( )
31+ return L2CAPSocketEventStream ( unfolding: {
32+ await iterator
33+ . next ( )
34+ . map { L2CAPSocketEvent ( $0) }
35+ } )
36+ } ( )
37+
2838 // MARK: - Initialization
2939
3040 deinit {
@@ -154,19 +164,6 @@ public final class L2CAPSocket: Bluetooth.L2CAPSocket {
154164
155165 // MARK: - Methods
156166
157- /// Set an event handler for the socket.
158- public func setEvent( _ eventHandler: @escaping ( ( L2CAPSocketEvent ) async -> ( ) ) ) async {
159- do {
160- try await socket. setEvent { socketEvent in
161- let event = L2CAPSocketEvent ( socketEvent)
162- Task { await eventHandler ( event) }
163- }
164- }
165- catch {
166- assertionFailure ( " Unable to set event " )
167- }
168- }
169-
170167 /// Attempt to accept an incoming connection.
171168 public func accept( ) async throws -> L2CAPSocket {
172169 let ( clientFileDescriptor, clientAddress) = try await socket. fileDescriptor. accept ( L2CAPSocketAddress . self, sleep: 100_000_000 )
You can’t perform that action at this time.
0 commit comments