Skip to content

Commit e4cb23d

Browse files
committed
MSRP: add asCapable check to onLeaveIndication
Factor out AS capable check into a new function, and ensure it is called both from onLeaveIndication as well as onJoinIndication.
1 parent e8cf126 commit e4cb23d

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

Sources/MRP/Applications/MSRP/MSRPApplication.swift

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,18 @@ extension MSRPApplication {
650650
}
651651
}
652652

653+
private func _checkAsCapable(port: P, attributeType: MSRPAttributeType, isJoin: Bool) async throws {
654+
guard !_ignoreAsCapable else { return }
655+
656+
guard await (try? port.isAsCapable) ?? false else {
657+
_logger
658+
.trace(
659+
"MSRP: ignoring \(isJoin ? "join" : "leave") indication for attribute \(attributeType) as port is not asCapable"
660+
)
661+
throw MRPError.doNotPropagateAttribute
662+
}
663+
}
664+
653665
private func _checkAvailableBandwidth(
654666
port: P,
655667
portState: MSRPPortState<P>,
@@ -1455,15 +1467,7 @@ extension MSRPApplication {
14551467
throw MRPError.doNotPropagateAttribute
14561468
}
14571469

1458-
if !_ignoreAsCapable {
1459-
guard await (try? port.isAsCapable) ?? false else {
1460-
_logger
1461-
.trace(
1462-
"MSRP: ignoring join indication for attribute \(attributeType) as port is not asCapable"
1463-
)
1464-
throw MRPError.doNotPropagateAttribute
1465-
}
1466-
}
1470+
try await _checkAsCapable(port: port, attributeType: attributeType, isJoin: true)
14671471

14681472
switch attributeType {
14691473
case .talkerAdvertise:
@@ -1659,6 +1663,8 @@ extension MSRPApplication {
16591663
throw MRPError.doNotPropagateAttribute
16601664
}
16611665

1666+
try await _checkAsCapable(port: port, attributeType: attributeType, isJoin: false)
1667+
16621668
switch attributeType {
16631669
case .talkerAdvertise:
16641670
try await _onDeregisterStreamIndication(

0 commit comments

Comments
 (0)