Handle indices

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner
2023-09-10 12:10:13 +02:00
parent a0f1184c40
commit 645b123bea
2 changed files with 16 additions and 13 deletions

View File

@@ -38,27 +38,32 @@ export class MatrixKeyProvider extends BaseKeyProvider {
this.onEncryptionKeyChanged this.onEncryptionKeyChanged
); );
// The new session could be aware of keys of which the old session wasn't,
// so emit a key changed event.
for (const [ for (const [
participant, participant,
encryptionKey, encryptionKeys,
] of this.rtcSession.getEncryptionKeys()) { ] of this.rtcSession.getEncryptionKeys()) {
// The new session could be aware of keys of which the old session wasn't, for (const [index, encryptionKey] of encryptionKeys.entries()) {
// so emit a key changed event. this.onEncryptionKeyChanged(encryptionKey, index, participant);
this.onEncryptionKeyChanged(encryptionKey, participant); }
} }
} }
private onEncryptionKeyChanged = async ( private onEncryptionKeyChanged = async (
encryptionKey: string, encryptionKey: string,
encryptionKeyIndex: number,
participantId: string participantId: string
) => { ) => {
console.log(
`Embedded-E2EE-LOG onEncryptionKeyChanged participantId=${participantId} encryptionKey=${encryptionKey}`
);
this.onSetEncryptionKey( this.onSetEncryptionKey(
await createKeyMaterialFromString(encryptionKey), await createKeyMaterialFromString(encryptionKey),
participantId participantId,
encryptionKeyIndex
);
console.log(
`Embedded-E2EE-LOG onEncryptionKeyChanged participantId=${participantId} encryptionKeyIndex=${encryptionKeyIndex} encryptionKey=${encryptionKey}`,
this.getKeys()
); );
}; };
} }

View File

@@ -176,12 +176,10 @@ export function InCallView({
const toggleMicrophone = useCallback(() => { const toggleMicrophone = useCallback(() => {
muteStates.audio.setEnabled?.((e) => !e); muteStates.audio.setEnabled?.((e) => !e);
rtcSession.updateEncryptionKeyEvent(); }, [muteStates]);
}, [muteStates, rtcSession]);
const toggleCamera = useCallback(() => { const toggleCamera = useCallback(() => {
muteStates.video.setEnabled?.((e) => !e); muteStates.video.setEnabled?.((e) => !e);
rtcSession.updateEncryptionKeyEvent(); }, [muteStates]);
}, [muteStates, rtcSession]);
const joinRule = useJoinRule(rtcSession.room); const joinRule = useJoinRule(rtcSession.room);