File tree Expand file tree Collapse file tree 6 files changed +57
-13
lines changed Expand file tree Collapse file tree 6 files changed +57
-13
lines changed Original file line number Diff line number Diff line change
1
+ minor type= "fixed" "Outgoing data packets missing local participant identity"
Original file line number Diff line number Diff line change @@ -102,6 +102,11 @@ extension Room {
102
102
log ( " publisher data channel is not .open " , . error)
103
103
}
104
104
105
+ var packet = packet
106
+ if let identity = localParticipant. identity? . stringValue {
107
+ packet. participantIdentity = identity
108
+ }
109
+
105
110
// Should return true if successful
106
111
try publisherDataChannel. send ( dataPacket: packet)
107
112
}
Original file line number Diff line number Diff line change @@ -93,6 +93,7 @@ final class IPCChannelTests: LKTestCase {
93
93
await fulfillment ( of: [ cancelThrowsError] , timeout: 5.0 )
94
94
}
95
95
96
+ // swiftformat:disable redundantSelf hoistAwait
96
97
func testConnectorCancelDuringInit( ) async throws {
97
98
try await assertInitCancellationThrows (
98
99
await IPCChannel ( connectingTo: self . socketPath)
@@ -105,6 +106,8 @@ final class IPCChannelTests: LKTestCase {
105
106
)
106
107
}
107
108
109
+ // swiftformat:enable all
110
+
108
111
private struct TestHeader : Codable , Equatable {
109
112
let someField : Int
110
113
}
Original file line number Diff line number Diff line change @@ -40,6 +40,24 @@ class RoomTests: LKTestCase {
40
40
// Nothing to do here
41
41
}
42
42
}
43
+
44
+ func testSendDataPacket( ) async throws {
45
+ try await withRooms ( [ RoomTestingOptions ( ) ] ) { rooms in
46
+ let room = rooms [ 0 ]
47
+
48
+ let expectDataPacket = self . expectation ( description: " Should send data packet " )
49
+
50
+ let mockDataChannel = MockDataChannelPair { packet in
51
+ XCTAssertEqual ( packet. participantIdentity, room. localParticipant. identity? . stringValue ?? " " )
52
+ expectDataPacket. fulfill ( )
53
+ }
54
+ room. publisherDataChannel = mockDataChannel
55
+
56
+ try await room. send ( dataPacket: Livekit_DataPacket ( ) )
57
+
58
+ await self . fulfillment ( of: [ expectDataPacket] , timeout: 5 )
59
+ }
60
+ }
43
61
}
44
62
45
63
extension RoomTests : RoomDelegate {
Original file line number Diff line number Diff line change 18
18
import XCTest
19
19
20
20
class RpcTests : LKTestCase {
21
- // Mock DataChannelPair to intercept outgoing packets
22
- class MockDataChannelPair : DataChannelPair {
23
- var packetHandler : ( Livekit_DataPacket ) -> Void
24
-
25
- init ( packetHandler: @escaping ( Livekit_DataPacket ) -> Void ) {
26
- self . packetHandler = packetHandler
27
- }
28
-
29
- override func send( dataPacket packet: Livekit_DataPacket ) throws {
30
- packetHandler ( packet)
31
- }
32
- }
33
-
34
21
// Test performing RPC calls and verifying outgoing packets
35
22
func testPerformRpc( ) async throws {
36
23
try await withRooms ( [ RoomTestingOptions ( ) ] ) { rooms in
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2025 LiveKit
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ @testable import LiveKit
18
+
19
+ /// Mock ``DataChannelPair`` to intercept outgoing packets.
20
+ class MockDataChannelPair : DataChannelPair {
21
+ var packetHandler : ( Livekit_DataPacket ) -> Void
22
+
23
+ init ( packetHandler: @escaping ( Livekit_DataPacket ) -> Void ) {
24
+ self . packetHandler = packetHandler
25
+ }
26
+
27
+ override func send( dataPacket packet: Livekit_DataPacket ) throws {
28
+ packetHandler ( packet)
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments