UNPKG

@observertc/client-monitor-js

Version:

ObserveRTC Client Integration Javascript Library

1 lines 1.49 kB
export class IceCandidateMonitor{_peerConnection;_visited=!0;timestamp;id;transportId;address;port;protocol;candidateType;priority;url;relayProtocol;foundation;relatedAddress;relatedPort;usernameFragment;tcpType;attachments;appData;constructor(t,e){this._peerConnection=t,this.id=e.id,this.timestamp=e.timestamp,Object.assign(this,e)}get visited(){const t=this._visited;return this._visited=!1,t}accept(t){this._visited=!0;t.timestamp-this.timestamp<=0||Object.assign(this,t)}getPeerConnection(){return this._peerConnection}getIceTransport(){return this._peerConnection.mappedIceTransportMonitors.get(this.transportId??"")}get isRelay(){return"relay"===this.candidateType||void 0!==this.turnTransport}get turnTransport(){switch(this.relayProtocol){case"udp":case"tcp":case"tls":return this.relayProtocol;default:return}}get turnServer(){if(this.isRelay&&this.url?.startsWith("turn"))return this.url.split("?")[0]}get addressFamily(){const t=this.address;if(t&&!t.endsWith(".local"))return t.includes(":")?"ipv6":/^\d{1,3}(\.\d{1,3}){3}$/.test(t)?"ipv4":void 0}createSample(){return{id:this.id,timestamp:this.timestamp,transportId:this.transportId,address:this.address,port:this.port,protocol:this.protocol,candidateType:this.candidateType,priority:this.priority,url:this.url,relayProtocol:this.relayProtocol,foundation:this.foundation,relatedAddress:this.relatedAddress,relatedPort:this.relatedPort,usernameFragment:this.usernameFragment,tcpType:this.tcpType,attachments:this.attachments}}}