@signalwire/js 3.26.0 → 3.27.0-dev.202404301530.94a97d7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/src/BaseComponent.d.ts +10 -0
- package/dist/core/src/BaseComponent.d.ts.map +1 -1
- package/dist/core/src/BaseJWTSession.d.ts.map +1 -1
- package/dist/core/src/BaseSession.d.ts +3 -0
- package/dist/core/src/BaseSession.d.ts.map +1 -1
- package/dist/core/src/RPCMessages/RPCConnect.d.ts +14 -0
- package/dist/core/src/RPCMessages/RPCConnect.d.ts.map +1 -1
- package/dist/core/src/index.d.ts +4 -3
- package/dist/core/src/index.d.ts.map +1 -1
- package/dist/core/src/memberPosition/workers.d.ts.map +1 -1
- package/dist/core/src/redux/index.d.ts +5 -0
- package/dist/core/src/redux/index.d.ts.map +1 -1
- package/dist/core/src/redux/interfaces.d.ts +2 -0
- package/dist/core/src/redux/interfaces.d.ts.map +1 -1
- package/dist/core/src/redux/utils/useInstanceMap.d.ts +2 -0
- package/dist/core/src/redux/utils/useInstanceMap.d.ts.map +1 -1
- package/dist/core/src/rooms/RoomSessionMember.d.ts +39 -0
- package/dist/core/src/rooms/RoomSessionMember.d.ts.map +1 -0
- package/dist/core/src/rooms/index.d.ts +1 -0
- package/dist/core/src/rooms/index.d.ts.map +1 -1
- package/dist/core/src/rooms/methods.d.ts +2 -2
- package/dist/core/src/rooms/methods.d.ts.map +1 -1
- package/dist/core/src/testUtils.d.ts +8 -0
- package/dist/core/src/testUtils.d.ts.map +1 -1
- package/dist/core/src/types/callSegment.d.ts +21 -0
- package/dist/core/src/types/callSegment.d.ts.map +1 -0
- package/dist/core/src/types/callfabric.d.ts +337 -16
- package/dist/core/src/types/callfabric.d.ts.map +1 -1
- package/dist/core/src/types/conversation.d.ts +24 -0
- package/dist/core/src/types/conversation.d.ts.map +1 -0
- package/dist/core/src/types/index.d.ts +15 -1
- package/dist/core/src/types/index.d.ts.map +1 -1
- package/dist/core/src/types/unified.d.ts +36 -0
- package/dist/core/src/types/unified.d.ts.map +1 -0
- package/dist/core/src/types/utils.d.ts +3 -0
- package/dist/core/src/types/utils.d.ts.map +1 -1
- package/dist/core/src/types/videoMember.d.ts +11 -1
- package/dist/core/src/types/videoMember.d.ts.map +1 -1
- package/dist/core/src/types/videoRoomSession.d.ts +3 -0
- package/dist/core/src/types/videoRoomSession.d.ts.map +1 -1
- package/dist/core/src/utils/index.d.ts +1 -0
- package/dist/core/src/utils/index.d.ts.map +1 -1
- package/dist/core/src/utils/interfaces.d.ts +16 -9
- package/dist/core/src/utils/interfaces.d.ts.map +1 -1
- package/dist/core/src/utils/mapObject.d.ts +7 -0
- package/dist/core/src/utils/mapObject.d.ts.map +1 -0
- package/dist/core/src/utils/mapObject.test.d.ts +2 -0
- package/dist/core/src/utils/mapObject.test.d.ts.map +1 -0
- package/dist/core/src/workers/executeActionWorker.d.ts.map +1 -1
- package/dist/index.esm.js +1352 -527
- package/dist/index.esm.js.map +3 -3
- package/dist/index.js +1448 -642
- package/dist/index.js.map +3 -3
- package/dist/index.umd.js +3 -3
- package/dist/index.umd.js.map +1 -1
- package/dist/js/src/BaseRoomSession.d.ts +6 -4
- package/dist/js/src/BaseRoomSession.d.ts.map +1 -1
- package/dist/js/src/Client.d.ts +1 -0
- package/dist/js/src/Client.d.ts.map +1 -1
- package/dist/js/src/JWTSession.d.ts.map +1 -1
- package/dist/js/src/UnifiedJWTSession.d.ts +16 -0
- package/dist/js/src/UnifiedJWTSession.d.ts.map +1 -0
- package/dist/js/src/fabric/CallFabricBaseRoomSession.d.ts +30 -0
- package/dist/js/src/fabric/CallFabricBaseRoomSession.d.ts.map +1 -0
- package/dist/js/src/fabric/CallSegment.d.ts +26 -0
- package/dist/js/src/fabric/CallSegment.d.ts.map +1 -0
- package/dist/js/src/fabric/Conversation.d.ts +144 -0
- package/dist/js/src/fabric/Conversation.d.ts.map +1 -0
- package/dist/js/src/fabric/ConversationAPI.d.ts +61 -0
- package/dist/js/src/fabric/ConversationAPI.d.ts.map +1 -0
- package/dist/js/src/fabric/HTTPClient.d.ts +45 -27
- package/dist/js/src/fabric/HTTPClient.d.ts.map +1 -1
- package/dist/js/src/fabric/IncomingCallManager.d.ts +14 -0
- package/dist/js/src/fabric/IncomingCallManager.d.ts.map +1 -0
- package/dist/js/src/fabric/SignalWire.d.ts +1 -16
- package/dist/js/src/fabric/SignalWire.d.ts.map +1 -1
- package/dist/js/src/fabric/WSClient.d.ts +23 -28
- package/dist/js/src/fabric/WSClient.d.ts.map +1 -1
- package/dist/js/src/fabric/createHttpClient.d.ts +1 -0
- package/dist/js/src/fabric/createHttpClient.d.ts.map +1 -1
- package/dist/js/src/fabric/index.d.ts +3 -0
- package/dist/js/src/fabric/index.d.ts.map +1 -1
- package/dist/js/src/fabric/types.d.ts +93 -0
- package/dist/js/src/fabric/types.d.ts.map +1 -0
- package/dist/js/src/fabric/workers/callFabricWorker.d.ts +7 -0
- package/dist/js/src/fabric/workers/callFabricWorker.d.ts.map +1 -0
- package/dist/js/src/fabric/workers/callJoinWorker.d.ts +4 -0
- package/dist/js/src/fabric/workers/callJoinWorker.d.ts.map +1 -0
- package/dist/js/src/fabric/workers/callLeftWorker.d.ts +4 -0
- package/dist/js/src/fabric/workers/callLeftWorker.d.ts.map +1 -0
- package/dist/js/src/fabric/workers/callStateWorker.d.ts +4 -0
- package/dist/js/src/fabric/workers/callStateWorker.d.ts.map +1 -0
- package/dist/js/src/fabric/workers/conversationWorker.d.ts +4 -0
- package/dist/js/src/fabric/workers/conversationWorker.d.ts.map +1 -0
- package/dist/js/src/fabric/workers/index.d.ts +6 -0
- package/dist/js/src/fabric/workers/index.d.ts.map +1 -0
- package/dist/js/src/fabric/workers/mappers/unifiedEventsMapper.d.ts +3 -0
- package/dist/js/src/fabric/workers/mappers/unifiedEventsMapper.d.ts.map +1 -0
- package/dist/js/src/fabric/workers/unifiedEventsWatcher.d.ts +7 -0
- package/dist/js/src/fabric/workers/unifiedEventsWatcher.d.ts.map +1 -0
- package/dist/js/src/fabric/workers/unifiedTargetWorker.d.ts +3 -0
- package/dist/js/src/fabric/workers/unifiedTargetWorker.d.ts.map +1 -0
- package/dist/js/src/fabric/{WSClientWorker.d.ts → workers/wsClientWorker.d.ts} +3 -3
- package/dist/js/src/fabric/workers/wsClientWorker.d.ts.map +1 -0
- package/dist/js/src/features/mediaElements/mediaElementsSagas.d.ts.map +1 -1
- package/dist/js/src/index.d.ts +7 -8
- package/dist/js/src/index.d.ts.map +1 -1
- package/dist/js/src/testUtils.d.ts +17 -0
- package/dist/js/src/testUtils.d.ts.map +1 -1
- package/dist/js/src/utils/UnifiedRequestMapper.d.ts +4 -0
- package/dist/js/src/utils/UnifiedRequestMapper.d.ts.map +1 -0
- package/dist/js/src/utils/aspectRatioListener.d.ts +8 -0
- package/dist/js/src/utils/aspectRatioListener.d.ts.map +1 -0
- package/dist/js/src/utils/interfaces.d.ts +3 -1
- package/dist/js/src/utils/interfaces.d.ts.map +1 -1
- package/dist/js/src/utils/makeQueryParamsUrl.d.ts +9 -0
- package/dist/js/src/utils/makeQueryParamsUrl.d.ts.map +1 -0
- package/dist/js/src/utils/paginatedResult.d.ts +44 -0
- package/dist/js/src/utils/paginatedResult.d.ts.map +1 -0
- package/dist/js/src/utils/videoElement.d.ts +4 -0
- package/dist/js/src/utils/videoElement.d.ts.map +1 -1
- package/dist/js/src/video/videoMemberWorker.d.ts +6 -0
- package/dist/js/src/video/videoMemberWorker.d.ts.map +1 -0
- package/dist/js/src/video/videoRoomWorker.d.ts +4 -0
- package/dist/js/src/video/videoRoomWorker.d.ts.map +1 -0
- package/dist/js/src/video/videoWorker.d.ts.map +1 -1
- package/dist/js/src/video/videoWorkerUnifiedEventing.d.ts +4 -0
- package/dist/js/src/video/videoWorkerUnifiedEventing.d.ts.map +1 -0
- package/dist/js/src/video/workers.d.ts +5 -0
- package/dist/js/src/video/workers.d.ts.map +1 -1
- package/dist/js/tsconfig.build.tsbuildinfo +1 -1
- package/dist/webrtc/src/BaseConnection.d.ts.map +1 -1
- package/dist/webrtc/src/RTCPeer.d.ts.map +1 -1
- package/dist/webrtc/src/workers/roomSubscribedWorker.d.ts.map +1 -1
- package/package.json +6 -3
- package/src/BaseRoomSession.test.ts +3 -2
- package/src/BaseRoomSession.ts +8 -2
- package/src/Client.ts +10 -2
- package/src/JWTSession.test.ts +2 -2
- package/src/JWTSession.ts +1 -1
- package/src/UnifiedJWTSession.ts +78 -0
- package/src/fabric/CallFabricBaseRoomSession.test.ts +460 -0
- package/src/fabric/CallFabricBaseRoomSession.ts +269 -0
- package/src/fabric/CallSegment.ts +83 -0
- package/src/fabric/Conversation.test.ts +257 -0
- package/src/fabric/Conversation.ts +150 -0
- package/src/fabric/ConversationAPI.ts +44 -0
- package/src/fabric/HTTPClient.test.ts +23 -18
- package/src/fabric/HTTPClient.ts +52 -55
- package/src/fabric/IncomingCallManager.test.ts +245 -0
- package/src/fabric/IncomingCallManager.ts +89 -0
- package/src/fabric/SignalWire.ts +20 -17
- package/src/fabric/WSClient.ts +153 -117
- package/src/fabric/createHttpClient.ts +2 -0
- package/src/fabric/index.ts +3 -0
- package/src/fabric/types.ts +104 -0
- package/src/fabric/workers/callFabricWorker.ts +121 -0
- package/src/fabric/workers/callJoinWorker.ts +90 -0
- package/src/fabric/workers/callLeftWorker.ts +47 -0
- package/src/fabric/workers/callStateWorker.ts +39 -0
- package/src/fabric/workers/conversationWorker.ts +41 -0
- package/src/fabric/workers/index.ts +5 -0
- package/src/fabric/workers/mappers/unifiedEventsMapper.ts +54 -0
- package/src/fabric/workers/unifiedEventsWatcher.ts +75 -0
- package/src/fabric/workers/unifiedTargetWorker.ts +96 -0
- package/src/fabric/{WSClientWorker.ts → workers/wsClientWorker.ts} +14 -18
- package/src/features/mediaElements/mediaElementsSagas.ts +9 -15
- package/src/index.ts +25 -9
- package/src/testUtils.ts +83 -0
- package/src/utils/UnifiedRequestMapper.ts +149 -0
- package/src/utils/aspectRatioListener.ts +40 -0
- package/src/utils/interfaces.ts +3 -0
- package/src/utils/makeQueryParamsUrl.ts +14 -0
- package/src/utils/paginatedResult.ts +34 -0
- package/src/utils/videoElement.ts +4 -0
- package/src/video/videoMemberWorker.ts +107 -0
- package/src/video/videoRoomWorker.ts +103 -0
- package/src/video/videoWorker.ts +8 -3
- package/src/video/videoWorkerUnifiedEventing.ts +95 -0
- package/src/video/workers.ts +5 -0
- package/dist/js/src/fabric/WSClientWorker.d.ts.map +0 -1
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
import { RoomSessionMember, actions, componentActions } from '@signalwire/core'
|
|
2
|
+
import { BaseRoomSession } from '../BaseRoomSession'
|
|
3
|
+
import { configureFullStack, dispatchMockedCallJoined } from '../testUtils'
|
|
4
|
+
import {
|
|
5
|
+
CallFabricRoomSessionConnection,
|
|
6
|
+
createCallFabricBaseRoomSessionObject,
|
|
7
|
+
} from './CallFabricBaseRoomSession'
|
|
8
|
+
|
|
9
|
+
describe('CallFabricBaseRoomSession', () => {
|
|
10
|
+
let store: any
|
|
11
|
+
let room: BaseRoomSession<CallFabricRoomSessionConnection> & {
|
|
12
|
+
execute: (params: any) => any
|
|
13
|
+
callSegments: any[]
|
|
14
|
+
}
|
|
15
|
+
let stack: ReturnType<typeof configureFullStack>
|
|
16
|
+
const callId = 'call-id-1'
|
|
17
|
+
|
|
18
|
+
const setupRoomForTests = () => {
|
|
19
|
+
const mockPeer = {
|
|
20
|
+
uuid: callId,
|
|
21
|
+
onRemoteSdp: jest.fn(),
|
|
22
|
+
}
|
|
23
|
+
// @ts-expect-error
|
|
24
|
+
room.getRTCPeerById = jest.fn((_id: string) => mockPeer)
|
|
25
|
+
|
|
26
|
+
// @ts-expect-error
|
|
27
|
+
room.runRTCPeerWorkers(callId)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
stack = configureFullStack()
|
|
32
|
+
store = stack.store
|
|
33
|
+
// @ts-expect-error
|
|
34
|
+
room =
|
|
35
|
+
createCallFabricBaseRoomSessionObject<CallFabricRoomSessionConnection>({
|
|
36
|
+
store,
|
|
37
|
+
// @ts-expect-error
|
|
38
|
+
emitter: stack.emitter,
|
|
39
|
+
})
|
|
40
|
+
store.dispatch(
|
|
41
|
+
componentActions.upsert({
|
|
42
|
+
id: callId,
|
|
43
|
+
nodeId: 'node-id',
|
|
44
|
+
roomId: 'room-id',
|
|
45
|
+
roomSessionId: 'room-session-id',
|
|
46
|
+
memberId: 'member-id',
|
|
47
|
+
})
|
|
48
|
+
)
|
|
49
|
+
room.execute = jest.fn()
|
|
50
|
+
|
|
51
|
+
setupRoomForTests()
|
|
52
|
+
|
|
53
|
+
// mock a call.joined event
|
|
54
|
+
dispatchMockedCallJoined({
|
|
55
|
+
session: stack.session,
|
|
56
|
+
callId: callId,
|
|
57
|
+
roomId: 'room-id-1',
|
|
58
|
+
roomSessionId: 'room-session-id-1',
|
|
59
|
+
memberId: 'member-id-1',
|
|
60
|
+
nodeId: 'node-id-1',
|
|
61
|
+
})
|
|
62
|
+
dispatchMockedCallJoined({
|
|
63
|
+
session: stack.session,
|
|
64
|
+
callId: 'call-id-2',
|
|
65
|
+
roomId: 'room-id-2',
|
|
66
|
+
roomSessionId: 'room-session-id-2',
|
|
67
|
+
memberId: 'member-id-2',
|
|
68
|
+
nodeId: 'node-id-2',
|
|
69
|
+
})
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
afterEach(() => {
|
|
73
|
+
stack.destroy()
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
describe('should use CallFabricRoomSessionConnection implementation', () => {
|
|
77
|
+
const roomActionParams = {
|
|
78
|
+
self: {
|
|
79
|
+
call_id: 'call-id-1',
|
|
80
|
+
member_id: 'member-id-1',
|
|
81
|
+
node_id: 'node-id-1',
|
|
82
|
+
},
|
|
83
|
+
}
|
|
84
|
+
const memberActionParams = {
|
|
85
|
+
self: {
|
|
86
|
+
call_id: 'call-id-1',
|
|
87
|
+
member_id: 'member-id-1',
|
|
88
|
+
node_id: 'node-id-1',
|
|
89
|
+
},
|
|
90
|
+
target: {
|
|
91
|
+
call_id: 'call-id-2',
|
|
92
|
+
member_id: 'member-id-2',
|
|
93
|
+
node_id: 'node-id-2',
|
|
94
|
+
},
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
test('audioMute implementation', async () => {
|
|
98
|
+
const spy = jest.spyOn(
|
|
99
|
+
CallFabricRoomSessionConnection.prototype,
|
|
100
|
+
'audioMute'
|
|
101
|
+
)
|
|
102
|
+
await room.audioMute({ memberId: 'member-id-2' })
|
|
103
|
+
expect(spy).toHaveBeenCalledWith({ memberId: 'member-id-2' })
|
|
104
|
+
expect(room.execute).toHaveBeenCalledWith(
|
|
105
|
+
{
|
|
106
|
+
method: 'call.mute',
|
|
107
|
+
params: {
|
|
108
|
+
channels: ['audio'],
|
|
109
|
+
...memberActionParams,
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
{}
|
|
113
|
+
)
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
test('audioUnmute implementation', async () => {
|
|
117
|
+
const spy = jest.spyOn(
|
|
118
|
+
CallFabricRoomSessionConnection.prototype,
|
|
119
|
+
'audioUnmute'
|
|
120
|
+
)
|
|
121
|
+
await room.audioUnmute({ memberId: 'member-id-2' })
|
|
122
|
+
expect(spy).toHaveBeenCalledWith({ memberId: 'member-id-2' })
|
|
123
|
+
expect(room.execute).toHaveBeenCalledWith(
|
|
124
|
+
{
|
|
125
|
+
method: 'call.unmute',
|
|
126
|
+
params: {
|
|
127
|
+
channels: ['audio'],
|
|
128
|
+
...memberActionParams,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
{}
|
|
132
|
+
)
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
test('videoMute implementation', async () => {
|
|
136
|
+
const spy = jest.spyOn(
|
|
137
|
+
CallFabricRoomSessionConnection.prototype,
|
|
138
|
+
'videoMute'
|
|
139
|
+
)
|
|
140
|
+
await room.videoMute({ memberId: 'member-id-2' })
|
|
141
|
+
expect(spy).toHaveBeenCalledWith({ memberId: 'member-id-2' })
|
|
142
|
+
expect(room.execute).toHaveBeenCalledWith(
|
|
143
|
+
{
|
|
144
|
+
method: 'call.mute',
|
|
145
|
+
params: {
|
|
146
|
+
channels: ['video'],
|
|
147
|
+
...memberActionParams,
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
{}
|
|
151
|
+
)
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
test('videoUnmute implementation', async () => {
|
|
155
|
+
const spy = jest.spyOn(
|
|
156
|
+
CallFabricRoomSessionConnection.prototype,
|
|
157
|
+
'videoUnmute'
|
|
158
|
+
)
|
|
159
|
+
await room.videoUnmute({ memberId: 'member-id-2' })
|
|
160
|
+
expect(spy).toHaveBeenCalledWith({ memberId: 'member-id-2' })
|
|
161
|
+
expect(room.execute).toHaveBeenCalledWith(
|
|
162
|
+
{
|
|
163
|
+
method: 'call.unmute',
|
|
164
|
+
params: {
|
|
165
|
+
channels: ['video'],
|
|
166
|
+
...memberActionParams,
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
{}
|
|
170
|
+
)
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
test('deaf implementation', async () => {
|
|
174
|
+
const spy = jest.spyOn(CallFabricRoomSessionConnection.prototype, 'deaf')
|
|
175
|
+
await room.deaf({ memberId: 'member-id-2' })
|
|
176
|
+
expect(spy).toHaveBeenCalledWith({ memberId: 'member-id-2' })
|
|
177
|
+
expect(room.execute).toHaveBeenCalledWith(
|
|
178
|
+
{
|
|
179
|
+
method: 'call.deaf',
|
|
180
|
+
params: {
|
|
181
|
+
...memberActionParams,
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
{}
|
|
185
|
+
)
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
test('undeaf implementation', async () => {
|
|
189
|
+
const spy = jest.spyOn(
|
|
190
|
+
CallFabricRoomSessionConnection.prototype,
|
|
191
|
+
'undeaf'
|
|
192
|
+
)
|
|
193
|
+
await room.undeaf({ memberId: 'member-id-2' })
|
|
194
|
+
expect(spy).toHaveBeenCalledWith({ memberId: 'member-id-2' })
|
|
195
|
+
expect(room.execute).toHaveBeenCalledWith(
|
|
196
|
+
{
|
|
197
|
+
method: 'call.undeaf',
|
|
198
|
+
params: {
|
|
199
|
+
...memberActionParams,
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
{}
|
|
203
|
+
)
|
|
204
|
+
})
|
|
205
|
+
|
|
206
|
+
test('getLayouts implementation', async () => {
|
|
207
|
+
const spy = jest.spyOn(
|
|
208
|
+
CallFabricRoomSessionConnection.prototype,
|
|
209
|
+
'getLayouts'
|
|
210
|
+
)
|
|
211
|
+
await room.getLayouts()
|
|
212
|
+
expect(spy).toHaveBeenCalledWith()
|
|
213
|
+
expect(room.execute).toHaveBeenCalledWith(
|
|
214
|
+
{
|
|
215
|
+
method: 'call.layout.list',
|
|
216
|
+
params: {
|
|
217
|
+
...roomActionParams,
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
{ transformResolve: expect.any(Function) }
|
|
221
|
+
)
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
test('getMembers implementation', async () => {
|
|
225
|
+
const spy = jest.spyOn(
|
|
226
|
+
CallFabricRoomSessionConnection.prototype,
|
|
227
|
+
'getMembers'
|
|
228
|
+
)
|
|
229
|
+
await room.getMembers()
|
|
230
|
+
expect(spy).toHaveBeenCalledWith()
|
|
231
|
+
expect(room.execute).toHaveBeenCalledWith(
|
|
232
|
+
{
|
|
233
|
+
method: 'call.member.list',
|
|
234
|
+
params: {
|
|
235
|
+
...roomActionParams,
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
{ transformResolve: expect.any(Function) }
|
|
239
|
+
)
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
test('removeMember implementation', async () => {
|
|
243
|
+
const spy = jest.spyOn(
|
|
244
|
+
CallFabricRoomSessionConnection.prototype,
|
|
245
|
+
'removeMember'
|
|
246
|
+
)
|
|
247
|
+
await room.removeMember({ memberId: 'member-id-1' })
|
|
248
|
+
expect(spy).toHaveBeenCalledWith({ memberId: 'member-id-1' })
|
|
249
|
+
expect(room.execute).toHaveBeenCalledWith(
|
|
250
|
+
{
|
|
251
|
+
method: 'call.member.remove',
|
|
252
|
+
params: {
|
|
253
|
+
...memberActionParams,
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
{}
|
|
257
|
+
)
|
|
258
|
+
})
|
|
259
|
+
|
|
260
|
+
test('setLayout implementation', async () => {
|
|
261
|
+
const spy = jest.spyOn(
|
|
262
|
+
CallFabricRoomSessionConnection.prototype,
|
|
263
|
+
'setLayout'
|
|
264
|
+
)
|
|
265
|
+
await room.setLayout({ name: 'layout-1' })
|
|
266
|
+
expect(spy).toHaveBeenCalledWith({ name: 'layout-1' })
|
|
267
|
+
expect(room.execute).toHaveBeenCalledWith(
|
|
268
|
+
{
|
|
269
|
+
method: 'call.layout.set',
|
|
270
|
+
params: {
|
|
271
|
+
...roomActionParams,
|
|
272
|
+
name: 'layout-1',
|
|
273
|
+
layout: undefined,
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
{}
|
|
277
|
+
)
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
test('setInputVolume implementation', async () => {
|
|
281
|
+
const spy = jest.spyOn(
|
|
282
|
+
CallFabricRoomSessionConnection.prototype,
|
|
283
|
+
'setInputVolume'
|
|
284
|
+
)
|
|
285
|
+
await room.setInputVolume({ volume: 10 })
|
|
286
|
+
expect(spy).toHaveBeenCalledWith({ volume: 10 })
|
|
287
|
+
expect(room.execute).toHaveBeenCalledWith(
|
|
288
|
+
{
|
|
289
|
+
method: 'call.microphone.volume.set',
|
|
290
|
+
params: {
|
|
291
|
+
...memberActionParams,
|
|
292
|
+
volume: 10,
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
{}
|
|
296
|
+
)
|
|
297
|
+
})
|
|
298
|
+
|
|
299
|
+
test('setOutputVolume implementation', async () => {
|
|
300
|
+
const spy = jest.spyOn(
|
|
301
|
+
CallFabricRoomSessionConnection.prototype,
|
|
302
|
+
'setOutputVolume'
|
|
303
|
+
)
|
|
304
|
+
await room.setOutputVolume({ volume: 10 })
|
|
305
|
+
expect(spy).toHaveBeenCalledWith({ volume: 10 })
|
|
306
|
+
expect(room.execute).toHaveBeenCalledWith(
|
|
307
|
+
{
|
|
308
|
+
method: 'video.member.set_output_volume',
|
|
309
|
+
params: {
|
|
310
|
+
...memberActionParams,
|
|
311
|
+
volume: 10,
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
{}
|
|
315
|
+
)
|
|
316
|
+
})
|
|
317
|
+
|
|
318
|
+
test('setInputSensitivity implementation', async () => {
|
|
319
|
+
const spy = jest.spyOn(
|
|
320
|
+
CallFabricRoomSessionConnection.prototype,
|
|
321
|
+
'setInputSensitivity'
|
|
322
|
+
)
|
|
323
|
+
await room.setInputSensitivity({ value: 10 })
|
|
324
|
+
expect(spy).toHaveBeenCalledWith({ value: 10 })
|
|
325
|
+
expect(room.execute).toHaveBeenCalledWith(
|
|
326
|
+
{
|
|
327
|
+
method: 'call.microphone.sensitivity.set',
|
|
328
|
+
params: {
|
|
329
|
+
...memberActionParams,
|
|
330
|
+
value: 10,
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
{}
|
|
334
|
+
)
|
|
335
|
+
})
|
|
336
|
+
})
|
|
337
|
+
|
|
338
|
+
describe('should handle call.joined event', () => {
|
|
339
|
+
const roomId = 'd8caec4b-ddc9-4806-b2d0-e7c7d5cefe79'
|
|
340
|
+
const roomSessionId = '638a54a7-61d8-4db0-bc24-426aee5cebcd'
|
|
341
|
+
const memberId = '465ea212-c456-423b-9bcc-838c5e1b2851'
|
|
342
|
+
|
|
343
|
+
it('should emit the room.subscribed event', (done) => {
|
|
344
|
+
room.on('room.subscribed', async (params) => {
|
|
345
|
+
expect(params.room_session.room_id).toEqual(roomId)
|
|
346
|
+
expect(params.room_session.room_session_id).toEqual(roomSessionId)
|
|
347
|
+
const { members, recordings, playbacks, streams } = params.room_session
|
|
348
|
+
expect(members).toHaveLength(2)
|
|
349
|
+
expect(members[0].member_id).toEqual(memberId)
|
|
350
|
+
members.forEach((member) => {
|
|
351
|
+
expect(member.visible).toEqual(true)
|
|
352
|
+
expect(member.audio_muted).toEqual(false)
|
|
353
|
+
expect(member.video_muted).toEqual(false)
|
|
354
|
+
expect(member.deaf).toEqual(false)
|
|
355
|
+
expect(member.meta).toStrictEqual({})
|
|
356
|
+
})
|
|
357
|
+
expect(recordings).toHaveLength(0)
|
|
358
|
+
expect(playbacks).toHaveLength(0)
|
|
359
|
+
expect(streams).toHaveLength(0)
|
|
360
|
+
done()
|
|
361
|
+
})
|
|
362
|
+
|
|
363
|
+
dispatchMockedCallJoined({
|
|
364
|
+
session: stack.session,
|
|
365
|
+
callId: callId,
|
|
366
|
+
roomId,
|
|
367
|
+
roomSessionId,
|
|
368
|
+
memberId,
|
|
369
|
+
nodeId: 'node-id-random',
|
|
370
|
+
})
|
|
371
|
+
})
|
|
372
|
+
|
|
373
|
+
it('should maintain callSegments array', () => {
|
|
374
|
+
// Since two call.joined has already been dispatched two times in the beforeEach
|
|
375
|
+
expect(room.callSegments).toHaveLength(2)
|
|
376
|
+
|
|
377
|
+
dispatchMockedCallJoined({
|
|
378
|
+
session: stack.session,
|
|
379
|
+
callId: callId,
|
|
380
|
+
roomId: 'room-id-3',
|
|
381
|
+
roomSessionId: 'room-session-id-3',
|
|
382
|
+
memberId: 'member-id-3',
|
|
383
|
+
nodeId: 'node-id-3',
|
|
384
|
+
})
|
|
385
|
+
|
|
386
|
+
expect(room.callSegments).toHaveLength(3)
|
|
387
|
+
|
|
388
|
+
const callLeft = JSON.parse(
|
|
389
|
+
`{"jsonrpc":"2.0","id":"cb78f2eb-6468-48ed-979d-a94fca47befe","method":"signalwire.event","params":{"params":{"room_session":{"room_id":"${roomId}","room_session_id":"${roomSessionId}","event_channel":"signalwire_0c1c9852-b9d4-4a18-ba3b-eeafe1ffe504_13451811-bd4c-4646-b3ce-250581a7956e_94df1ecd-d073-473d-aa4d-a286e24f679b","layout_name":"1x1","meta":{},"members":[{"type":"member","call_id":"${callId}","member_id":"${memberId}","node_id":"6b706dc1-06ce-41db-8ad0-ad5c1c7f48d8@puc","name":"sip:foo@94df1ecd-d073-473d-aa4d-a286e24f679b.call.signalwire.com;context=private","room_id":"${roomId}","room_session_id":"${roomSessionId}","visible":true,"handraised":false,"audio_muted":false,"video_muted":false,"deaf":false,"meta":{}}],"recordings":[],"streams":[],"playbacks":[]},"room_id":"${roomId}","room_session_id":"${roomSessionId}","call_id":"${callId}","member_id":"${memberId}","node_id":"6b706dc1-06ce-41db-8ad0-ad5c1c7f48d8@puc"},"event_type":"call.left","event_channel":"signalwire_0c1c9852-b9d4-4a18-ba3b-eeafe1ffe504_13451811-bd4c-4646-b3ce-250581a7956e_94df1ecd-d073-473d-aa4d-a286e24f679b","timestamp":1712142454.67701}}`
|
|
390
|
+
)
|
|
391
|
+
stack.session.dispatch(actions.socketMessageAction(callLeft))
|
|
392
|
+
|
|
393
|
+
expect(room.callSegments).toHaveLength(2)
|
|
394
|
+
})
|
|
395
|
+
})
|
|
396
|
+
|
|
397
|
+
describe('should use correct self and target', () => {
|
|
398
|
+
it("should use current segment's memberId when provided with a self memberId from the previous segment", async () => {
|
|
399
|
+
dispatchMockedCallJoined({
|
|
400
|
+
session: stack.session,
|
|
401
|
+
callId: 'call-id-3',
|
|
402
|
+
roomId: 'room-id-3',
|
|
403
|
+
roomSessionId: 'room-session-id-3',
|
|
404
|
+
memberId: 'member-id-3',
|
|
405
|
+
nodeId: 'node-id-3',
|
|
406
|
+
})
|
|
407
|
+
|
|
408
|
+
expect(room.callSegments).toHaveLength(3)
|
|
409
|
+
room.callSegments.forEach((segment, index) => {
|
|
410
|
+
expect(segment.memberId).toBe(`member-id-${index + 1}`)
|
|
411
|
+
})
|
|
412
|
+
|
|
413
|
+
await room.audioMute({ memberId: 'member-id-2' })
|
|
414
|
+
|
|
415
|
+
expect(room.execute).toHaveBeenCalledWith(
|
|
416
|
+
{
|
|
417
|
+
method: 'call.mute',
|
|
418
|
+
params: {
|
|
419
|
+
channels: ['audio'],
|
|
420
|
+
self: {
|
|
421
|
+
call_id: 'call-id-1',
|
|
422
|
+
member_id: 'member-id-1',
|
|
423
|
+
node_id: 'node-id-1',
|
|
424
|
+
},
|
|
425
|
+
target: {
|
|
426
|
+
call_id: 'call-id-3',
|
|
427
|
+
member_id: 'member-id-3',
|
|
428
|
+
node_id: 'node-id-3',
|
|
429
|
+
},
|
|
430
|
+
},
|
|
431
|
+
},
|
|
432
|
+
{}
|
|
433
|
+
)
|
|
434
|
+
})
|
|
435
|
+
|
|
436
|
+
it('should throw error for invalid memberId not present in the current segment and not a self memberId', async () => {
|
|
437
|
+
dispatchMockedCallJoined({
|
|
438
|
+
session: stack.session,
|
|
439
|
+
callId: 'call-id-3',
|
|
440
|
+
roomId: 'room-id-3',
|
|
441
|
+
roomSessionId: 'room-session-id-3',
|
|
442
|
+
memberId: 'member-id-3',
|
|
443
|
+
memberId2: 'member-id-4',
|
|
444
|
+
nodeId: 'node-id-3',
|
|
445
|
+
})
|
|
446
|
+
|
|
447
|
+
expect(room.callSegments).toHaveLength(3)
|
|
448
|
+
expect(room.callSegments[2].members).toHaveLength(2)
|
|
449
|
+
room.callSegments[2].members.forEach((member: RoomSessionMember) => {
|
|
450
|
+
expect(member.id).not.toBe('member-id-random')
|
|
451
|
+
})
|
|
452
|
+
|
|
453
|
+
expect(async () => {
|
|
454
|
+
await room.audioMute({ memberId: 'member-id-random' })
|
|
455
|
+
}).rejects.toThrow(
|
|
456
|
+
'The memberId is not a part of the current call segment!'
|
|
457
|
+
)
|
|
458
|
+
})
|
|
459
|
+
})
|
|
460
|
+
})
|