From dad425e768f0259cadf79fe7aa004efb8f5a536e Mon Sep 17 00:00:00 2001 From: Filip Nowakowski Date: Tue, 13 Feb 2024 15:47:06 +0100 Subject: [PATCH] fix(webrtc-core): added onSuccess suffix to new events --- cspell.json | 6 +++--- src/peer-connection.spec.ts | 6 +++--- src/peer-connection.ts | 18 +++++++++--------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/cspell.json b/cspell.json index 18fe2d6..01ad5b3 100644 --- a/cspell.json +++ b/cspell.json @@ -37,9 +37,9 @@ "WCME", "webex", "webrtc", - "createoffer", - "setlocaldescription", - "setremotedescription" + "createofferonsuccess", + "setlocaldescriptiononsuccess", + "setremotedescriptiononsuccess" ], "flagWords": [], "ignorePaths": [ diff --git a/src/peer-connection.spec.ts b/src/peer-connection.spec.ts index d0387f8..64f1937 100644 --- a/src/peer-connection.spec.ts +++ b/src/peer-connection.spec.ts @@ -273,7 +273,7 @@ describe('PeerConnection', () => { mockCreateRTCPeerConnection.mockReturnValueOnce(mockPc as unknown as RTCPeerConnection); pc = new PeerConnection(); createOfferSpy = jest.spyOn(pc, 'createOffer'); - pc.on(PeerConnection.Events.CreateOffer, callback); + pc.on(PeerConnection.Events.CreateOfferOnSuccess, callback); }); it('should emit event when createOffer called', async () => { @@ -317,7 +317,7 @@ describe('PeerConnection', () => { }); setLocalDescriptionSpy = jest.spyOn(mockPc, 'setLocalDescription'); pc = new PeerConnection(); - pc.on(PeerConnection.Events.SetLocalDescription, callback); + pc.on(PeerConnection.Events.SetLocalDescriptionOnSuccess, callback); }); it('sets the local description with an SDP offer', async () => { @@ -382,7 +382,7 @@ describe('PeerConnection', () => { mockCreateRTCPeerConnection.mockReturnValueOnce(mockPc as unknown as RTCPeerConnection); pc = new PeerConnection(); setRemoteDescriptionSpy = jest.spyOn(pc, 'setRemoteDescription'); - pc.on(PeerConnection.Events.SetRemoteDescription, callback); + pc.on(PeerConnection.Events.SetRemoteDescriptionOnSuccess, callback); }); it('should emit event when setRemoteDescription called', async () => { diff --git a/src/peer-connection.ts b/src/peer-connection.ts index 608497b..433cc2d 100644 --- a/src/peer-connection.ts +++ b/src/peer-connection.ts @@ -28,19 +28,19 @@ type IceGatheringStateChangeEvent = { enum PeerConnectionEvents { IceGatheringStateChange = 'icegatheringstatechange', ConnectionStateChange = 'connectionstatechange', - CreateOffer = 'createoffer', - SetLocalDescription = 'setlocaldescription', - SetRemoteDescription = 'setremotedescription', + CreateOfferOnSuccess = 'createofferonsuccess', + SetLocalDescriptionOnSuccess = 'setlocaldescriptiononsuccess', + SetRemoteDescriptionOnSuccess = 'setremotedescriptiononsuccess', } interface PeerConnectionEventHandlers extends EventMap { [PeerConnectionEvents.IceGatheringStateChange]: (ev: IceGatheringStateChangeEvent) => void; [PeerConnectionEvents.ConnectionStateChange]: (state: ConnectionState) => void; - [PeerConnectionEvents.CreateOffer]: (offer: RTCSessionDescriptionInit) => void; - [PeerConnectionEvents.SetLocalDescription]: ( + [PeerConnectionEvents.CreateOfferOnSuccess]: (offer: RTCSessionDescriptionInit) => void; + [PeerConnectionEvents.SetLocalDescriptionOnSuccess]: ( description: RTCSessionDescription | RTCSessionDescriptionInit ) => void; - [PeerConnectionEvents.SetRemoteDescription]: ( + [PeerConnectionEvents.SetRemoteDescriptionOnSuccess]: ( description: RTCSessionDescription | RTCSessionDescriptionInit ) => void; } @@ -198,7 +198,7 @@ class PeerConnection extends EventEmitter { */ async createOffer(options?: RTCOfferOptions): Promise { return this.pc.createOffer(options).then((offer) => { - this.emit(PeerConnection.Events.CreateOffer, offer); + this.emit(PeerConnection.Events.CreateOfferOnSuccess, offer); return offer; }); } @@ -231,7 +231,7 @@ class PeerConnection extends EventEmitter { return this.pc.setLocalDescription(description).then(() => { if (description) { - this.emit(PeerConnection.Events.SetLocalDescription, description); + this.emit(PeerConnection.Events.SetLocalDescriptionOnSuccess, description); } }); } @@ -249,7 +249,7 @@ class PeerConnection extends EventEmitter { description: RTCSessionDescription | RTCSessionDescriptionInit ): Promise { return this.pc.setRemoteDescription(description).then(() => { - this.emit(PeerConnection.Events.SetRemoteDescription, description); + this.emit(PeerConnection.Events.SetRemoteDescriptionOnSuccess, description); }); }