import { ClusterNode } from './request'; import EventsScope from '../common/events/events-scope'; import { ClusterReachabilityResult } from './reachability.types'; /** * A class to handle RTCPeerConnection lifecycle and ICE candidate gathering for reachability checks. * It will do all the work like PeerConnection lifecycle, candidate processing, result management, and event emission. */ export declare class ReachabilityPeerConnection extends EventsScope { numUdpUrls: number; numTcpUrls: number; numXTlsUrls: number; private pc; private defer; private startTimestamp; private srflxIceCandidates; private clusterName; private result; private emittedSubnets; /** * Constructor for ReachabilityPeerConnection * @param {string} clusterName name of the cluster * @param {ClusterNode} clusterInfo information about the media cluster */ constructor(clusterName: string, clusterInfo: ClusterNode); /** * Gets total elapsed time, can be called only after start() is called * @returns {number} Milliseconds */ private getElapsedTime; /** * Generate peerConnection config settings * @param {ClusterNode} cluster * @returns {RTCConfiguration} peerConnectionConfig */ private static buildPeerConnectionConfig; /** * Creates an RTCPeerConnection * @param {ClusterNode} clusterInfo information about the media cluster * @returns {RTCPeerConnection|null} peerConnection */ private createPeerConnection; /** * @returns {ClusterReachabilityResult} reachability result for this instance */ getResult(): ClusterReachabilityResult; /** * Closes the peerConnection * @returns {void} */ private closePeerConnection; /** * Resolves the defer, indicating that reachability checks for this cluster are completed * * @returns {void} */ private finishReachabilityCheck; /** * Aborts the cluster reachability checks by closing the peer connection * * @returns {void} */ abort(): void; /** * Adds public IP (client media IPs) * @param {string} protocol * @param {string} publicIp * @returns {void} */ private addPublicIp; /** * Registers a listener for the iceGatheringStateChange event * * @returns {void} */ private registerIceGatheringStateChangeListener; /** * Saves the latency in the result for the given protocol and marks it as reachable, * emits the "resultReady" event if this is the first result for that protocol, * emits the "clientMediaIpsUpdated" event if we already had a result and only found * a new client IP * * @param {string} protocol * @param {number} latency * @param {string|null} [publicIp] * @param {string|null} [serverIp] * @returns {void} */ private saveResult; /** * Determines NAT type by analyzing server reflexive candidate patterns * @param {RTCIceCandidate} candidate server reflexive candidate * @returns {void} */ private determineNatTypeForSrflxCandidate; /** * Registers a listener for the icecandidate event * * @returns {void} */ private registerIceCandidateListener; /** * Starts the process of doing UDP, TCP, and XTLS reachability checks. * @returns {Promise} */ start(): Promise; /** * Starts the process of gathering ICE candidates * @returns {Promise} promise that's resolved once reachability checks are completed or timeout is reached */ private gatherIceCandidates; }