关于录屏相关的消息格式需要封一层,放在on-message下,利用on-message传递

This commit is contained in:
2026-06-02 23:17:15 +08:00
parent 59fc4be5cc
commit 206a3ac91d
5 changed files with 242 additions and 65 deletions

View File

@@ -8,6 +8,20 @@ Date.now = jest.fn(() => 1482363367071);
const anyParticipantId = expect.any(String);
function recordingEnvelope(connectionId: string, data: any): any {
const innerData = { ...data };
delete innerData.type;
return {
from: connectionId,
to: "",
type: "on-message",
data: JSON.stringify({
type: data.type,
data: innerData
})
};
}
describe('websocket signaling test in public mode', () => {
let server: WS;
let client: WebSocket;
@@ -212,20 +226,17 @@ describe('websocket signaling test in private mode', () => {
};
expect(wsHandler.broadcastRecordingStarted(session)).toBe(true);
await expect(server).toReceiveMessage(expected);
await expect(server).toReceiveMessage(expected);
await expect(server).toReceiveMessage(recordingEnvelope(connectionId, expected));
await expect(server).toReceiveMessage(recordingEnvelope(connectionId, expected));
expect(wsHandler.broadcastRecordingPeerRequest(session)).toBe(true);
await expect(server).toReceiveMessage({
const peerRequest = {
...expected,
type: 'recording-peer-request',
mediaMode: 'webrtc-sendonly'
});
await expect(server).toReceiveMessage({
...expected,
type: 'recording-peer-request',
mediaMode: 'webrtc-sendonly'
});
};
await expect(server).toReceiveMessage(recordingEnvelope(connectionId, peerRequest));
await expect(server).toReceiveMessage(recordingEnvelope(connectionId, peerRequest));
});
test('send offer from session1', async () => {