Skip to content

Commit e29d670

Browse files
committed
updated classnames for unit testing
1 parent d27cc76 commit e29d670

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

lib/src/components/VideoCall.tsx

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -204,16 +204,16 @@ const VideoCall = ({ URL, mediaOptions }: { URL: string, mediaOptions: { control
204204

205205
/**
206206
* @function callUser - Constructs a new RTCPeerConnection object using the createPeer function and then adds the local client's (Peer A/caller) media tracks to peer connection ref object.
207-
* @param {string} userID
207+
* @param {string} userID the remote client's (Peer B/callee) username
208208
*/
209209
const callUser = (userID: string): void => {
210210
peerRef.current = createPeer(userID);
211211
localStreamRef.current.getTracks().forEach((track) => senders.current.push(peerRef.current.addTrack(track, localStreamRef.current)));
212212
};
213213

214214
/**
215-
* @function createPeer - Creates a new RTCPeerConnection object, which represents a WebRTC connection between the local device and a remote peer and adds event listeners to it
216-
* @param {string} userID
215+
* @function createPeer - Creates a new RTCPeerConnection object, which represents a WebRTC connection between the local device and a remote peer and adds event listeners (handleIceCandidateEvent, handleTrackEvent, handleNegotiationNeededEvent) to it
216+
* @param {string} userID the remote client's (Peer B/callee) username
217217
* @returns {RTCPeerConnection} RTCPeerConnection object
218218
* @see https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/connectionstatechange_event and other events
219219
* @see https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/RTCPeerConnection
@@ -252,8 +252,12 @@ const VideoCall = ({ URL, mediaOptions }: { URL: string, mediaOptions: { control
252252

253253
/**
254254
* @function handleNegotiationNeededEvent
255-
* @desc invokes WebRTC's built-in createOffer() function to create an SDP offer, which is an RTCSessionDescription object. This offer is then set as the local description using WebRTC's built-in setLocalDescription() function. Finally, the offer, sender and receiver is sent via ws.current.send to the Signaling Channel in the backend
256-
* @param {string} userID
255+
* @desc creates an SDP offer and sends it through the signaling channel to the remote peer: invokes WebRTC's built-in createOffer() function to create an SDP offer, which is an RTCSessionDescription object. After creating the offer, the local end is configured by calling RTCPeerConnection.setLocalDescription().
256+
*
257+
* Then a signaling message is created and sent to the remote peer through the signaling server, to share the offer with the other peer. The other peer should recognize this message and follow up by creating its own RTCPeerConnection, setting the remote description with setRemoteDescription(), and then creating an answer to send back to the offering peer. Finally, the offer, sender and receiver is sent via ws.current.send to the Signaling Channel in the backend
258+
*
259+
* @param {string} userID the remote client's (Peer B/callee) username
260+
* @see https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/negotiationneeded_event
257261
*/
258262
function handleNegotiationNeededEvent(userID: string): void {
259263
peerRef.current?.createOffer()
@@ -263,7 +267,7 @@ const VideoCall = ({ URL, mediaOptions }: { URL: string, mediaOptions: { control
263267
.then(() => {
264268
const offerPayload: offerPayObj = {
265269
ACTION_TYPE: OFFER,
266-
sender: username,
270+
sender: username, // local peer
267271
receiver: userID,
268272
payload: peerRef.current?.localDescription
269273
};
@@ -498,14 +502,14 @@ const VideoCall = ({ URL, mediaOptions }: { URL: string, mediaOptions: { control
498502
>
499503
<input
500504
className='input-username'
501-
type='text'
502-
placeholder='username'
503505
id="username-field"
504-
onChange={(e) => userField = e.target.value}
506+
onChange={(e) => userField = e.target.value}
507+
placeholder='username'
505508
style={{
506509
paddingBottom:'40px',
507510
width:'200px'
508-
}}
511+
}}
512+
type='text'
509513
></input>
510514

511515
<button
@@ -546,8 +550,8 @@ const VideoCall = ({ URL, mediaOptions }: { URL: string, mediaOptions: { control
546550
}
547551

548552
<div
549-
id="main-video-container"
550553
className=''
554+
id="main-video-container"
551555
style= {{
552556
alignItems:'center',
553557
display: 'flex',
@@ -558,8 +562,8 @@ const VideoCall = ({ URL, mediaOptions }: { URL: string, mediaOptions: { control
558562
>
559563

560564
<div
561-
id="local-video-container"
562565
className=''
566+
id="local-video-container"
563567
style={{
564568
alignContent: 'center',
565569
display:'flex',
@@ -574,8 +578,8 @@ const VideoCall = ({ URL, mediaOptions }: { URL: string, mediaOptions: { control
574578
/>
575579

576580
<div
577-
id="local-button-container"
578581
className=''
582+
id="local-button-container"
579583
style= {{
580584
display: 'flex',
581585
flexDirection: 'row',
@@ -631,8 +635,8 @@ const VideoCall = ({ URL, mediaOptions }: { URL: string, mediaOptions: { control
631635
</div>
632636

633637
<div
634-
id="remote-video-container"
635638
className=''
639+
id="remote-video-container"
636640
style={{
637641
alignContent: 'center',
638642
display:'flex',
@@ -646,8 +650,8 @@ const VideoCall = ({ URL, mediaOptions }: { URL: string, mediaOptions: { control
646650
/>
647651

648652
<div
653+
className=''
649654
id="remote-button-container"
650-
className=''
651655
style= {{
652656
display: 'flex',
653657
flexDirection: 'row',
@@ -681,8 +685,8 @@ const VideoCall = ({ URL, mediaOptions }: { URL: string, mediaOptions: { control
681685

682686
<input
683687
className='input-receiver-name'
684-
type='text'
685688
id='receiverName'
689+
type='text'
686690
style={{
687691
marginLeft:'2%'
688692
}}></input>

0 commit comments

Comments
 (0)