Skip to content

Commit c5c0de3

Browse files
committed
linting error fix
1 parent 88ad37d commit c5c0de3

File tree

1 file changed

+89
-86
lines changed

1 file changed

+89
-86
lines changed

modules/proxyconnection/ProxyConnectionPC.ts

Lines changed: 89 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,33 @@ import { getLogger } from '@jitsi/logger';
22

33
import RTCEvents from '../../service/RTC/RTCEvents';
44
import { XMPPEvents } from '../../service/xmpp/XMPPEvents';
5-
import RTC from '../RTC/RTC';
65
import JitsiLocalTrack from '../RTC/JitsiLocalTrack';
76
import JitsiRemoteTrack from '../RTC/JitsiRemoteTrack';
7+
import JitsiTrack from '../RTC/JitsiTrack';
8+
import RTC from '../RTC/RTC';
9+
import ChatRoom from '../xmpp/ChatRoom';
810
import JingleSessionPC from '../xmpp/JingleSessionPC';
11+
import XmppConnection from '../xmpp/XmppConnection';
912
import { DEFAULT_STUN_SERVERS } from '../xmpp/xmpp';
10-
import ChatRoom from '../xmpp/ChatRoom';
1113

1214
import CustomSignalingLayer from './CustomSignalingLayer';
1315
import { ACTIONS } from './constants';
14-
import JitsiTrack from '../RTC/JitsiTrack';
15-
import XmppConnection from '../xmpp/XmppConnection';
16+
1617

1718
const logger = getLogger('modules/proxyconnection/ProxyConnectionPC');
1819

1920
/**
2021
* Interface for ProxyConnectionPC options
2122
*/
2223
interface IProxyConnectionPCOptions {
23-
pcConfig?: RTCConfiguration;
2424
isInitiator?: boolean;
25+
onError: (peerJid: string, errorType: string, details?: string) => void;
2526
onRemoteStream: (jitsiRemoteTrack: JitsiRemoteTrack) => void;
27+
onSendMessage: (peerJid: string, iq: Element) => void;
28+
pcConfig?: RTCConfiguration;
2629
peerJid: string;
2730
receiveAudio?: boolean;
2831
receiveVideo?: boolean;
29-
onSendMessage: (peerJid: string, iq: Element) => void;
30-
onError: (peerJid: string, errorType: string, details?: string) => void;
3132
}
3233

3334
/**
@@ -51,13 +52,13 @@ export default class ProxyConnectionPC {
5152
constructor(options: Partial<IProxyConnectionPCOptions> = {}) {
5253
this._options = {
5354
isInitiator: false,
55+
onError: () => { /* no-op */ },
56+
onRemoteStream: () => { /* no-op */ },
57+
onSendMessage: () => { /* no-op */ },
5458
pcConfig: {},
59+
peerJid: '',
5560
receiveAudio: false,
5661
receiveVideo: false,
57-
onRemoteStream: () => { /* no-op */ },
58-
peerJid: '',
59-
onSendMessage: () => { /* no-op */ },
60-
onError: () => { /* no-op */ },
6162
...options
6263
} as IProxyConnectionPCOptions;
6364

@@ -82,77 +83,6 @@ export default class ProxyConnectionPC {
8283
this._onSendMessage = this._onSendMessage.bind(this);
8384
}
8485

85-
/**
86-
* Returns the jid of the remote peer with which this peer connection should
87-
* be established with.
88-
*
89-
* @returns {string}
90-
*/
91-
getPeerJid() {
92-
return this._options.peerJid;
93-
}
94-
95-
/**
96-
* Updates the peer connection based on the passed in jingle.
97-
*
98-
* @param {Object} $jingle - An XML jingle element, wrapped in query,
99-
* describing how the peer connection should be updated.
100-
* @returns {void}
101-
*/
102-
processMessage($jingle: Element): void {
103-
switch ($jingle.getAttribute('action')) {
104-
case ACTIONS.ACCEPT:
105-
this._onSessionAccept($jingle);
106-
break;
107-
108-
case ACTIONS.INITIATE:
109-
this._onSessionInitiate($jingle);
110-
break;
111-
112-
case ACTIONS.TERMINATE:
113-
this._onSessionTerminate();
114-
break;
115-
116-
case ACTIONS.TRANSPORT_INFO:
117-
this._onTransportInfo($jingle);
118-
break;
119-
}
120-
}
121-
122-
/**
123-
* Instantiates a peer connection and starts the offer/answer cycle to
124-
* establish a connection with a remote peer.
125-
*
126-
* @param {Array<JitsiLocalTrack>} localTracks - Initial local tracks to add
127-
* to add to the peer connection.
128-
* @returns {void}
129-
*/
130-
start(localTracks: JitsiLocalTrack[] = []): void {
131-
if (this._peerConnection) {
132-
return;
133-
}
134-
135-
this._tracks = this._tracks.concat(localTracks);
136-
137-
this._peerConnection = this._createPeerConnection();
138-
139-
this._peerConnection.invite(localTracks);
140-
}
141-
142-
/**
143-
* Begins the process of disconnecting from a remote peer and cleaning up
144-
* the peer connection.
145-
*
146-
* @returns {void}
147-
*/
148-
stop(): void {
149-
if (this._peerConnection) {
150-
this._peerConnection.terminate();
151-
}
152-
153-
this._onSessionTerminate();
154-
}
155-
15686
/**
15787
* Instantiates a new {@code JingleSessionPC} by stubbing out the various
15888
* dependencies of {@code JingleSessionPC}.
@@ -180,16 +110,17 @@ export default class ProxyConnectionPC {
180110
const connectionStub: Partial<XmppConnection> = {
181111
// At the time this is used for Spot and it's okay to say the connection is always connected, because if
182112
// spot has no signalling it will not be in a meeting where this is used.
183-
// eslint-disable-next-line no-empty-function
113+
// eslint-disable-next-line @typescript-eslint/no-empty-function
184114
addCancellableListener: () => () => { },
185-
// eslint-disable-next-line no-empty-function
115+
// eslint-disable-next-line @typescript-eslint/no-empty-function
186116
addEventListener: () => () => { },
187117
connected: true,
188118
jingle: {
189119
terminate: () => { /** no-op */ }
190120
} as any,
191-
sendIQ: (elem: Element, callback?: any, errback?: any, timeout?: number) => {
121+
sendIQ: (elem: Element, callback?: any) => {
192122
this._onSendMessage(elem, callback);
123+
193124
return 0;
194125
}
195126
};
@@ -219,13 +150,14 @@ export default class ProxyConnectionPC {
219150
* @type {Function}
220151
* @returns {void}
221152
*/
222-
const emitter = (event: string, ...args: any[]): boolean => {
153+
const emitter = (event: string): boolean => {
223154
switch (event) {
224155
case XMPPEvents.CONNECTION_ICE_FAILED:
225156
case XMPPEvents.CONNECTION_FAILED:
226157
this._onError(ACTIONS.CONNECTION_ERROR, event);
227158
break;
228159
}
160+
229161
return true; // EventEmitter.emit should return boolean
230162
};
231163

@@ -428,4 +360,75 @@ export default class ProxyConnectionPC {
428360
private _onTransportInfo($jingle: Element): void {
429361
this._peerConnection.addIceCandidates($jingle);
430362
}
363+
364+
/**
365+
* Returns the jid of the remote peer with which this peer connection should
366+
* be established with.
367+
*
368+
* @returns {string}
369+
*/
370+
getPeerJid() {
371+
return this._options.peerJid;
372+
}
373+
374+
/**
375+
* Updates the peer connection based on the passed in jingle.
376+
*
377+
* @param {Object} $jingle - An XML jingle element, wrapped in query,
378+
* describing how the peer connection should be updated.
379+
* @returns {void}
380+
*/
381+
processMessage($jingle: Element): void {
382+
switch ($jingle.getAttribute('action')) {
383+
case ACTIONS.ACCEPT:
384+
this._onSessionAccept($jingle);
385+
break;
386+
387+
case ACTIONS.INITIATE:
388+
this._onSessionInitiate($jingle);
389+
break;
390+
391+
case ACTIONS.TERMINATE:
392+
this._onSessionTerminate();
393+
break;
394+
395+
case ACTIONS.TRANSPORT_INFO:
396+
this._onTransportInfo($jingle);
397+
break;
398+
}
399+
}
400+
401+
/**
402+
* Instantiates a peer connection and starts the offer/answer cycle to
403+
* establish a connection with a remote peer.
404+
*
405+
* @param {Array<JitsiLocalTrack>} localTracks - Initial local tracks to add
406+
* to add to the peer connection.
407+
* @returns {void}
408+
*/
409+
start(localTracks: JitsiLocalTrack[] = []): void {
410+
if (this._peerConnection) {
411+
return;
412+
}
413+
414+
this._tracks = this._tracks.concat(localTracks);
415+
416+
this._peerConnection = this._createPeerConnection();
417+
418+
this._peerConnection.invite(localTracks);
419+
}
420+
421+
/**
422+
* Begins the process of disconnecting from a remote peer and cleaning up
423+
* the peer connection.
424+
*
425+
* @returns {void}
426+
*/
427+
stop(): void {
428+
if (this._peerConnection) {
429+
this._peerConnection.terminate();
430+
}
431+
432+
this._onSessionTerminate();
433+
}
431434
}

0 commit comments

Comments
 (0)