simli-client
Advanced tools
@@ -72,2 +72,3 @@ interface SimliClientConfig { | ||
| private inputIceServers; | ||
| config: SimliClientConfig | null; | ||
| on<K extends keyof SimliClientEvents>(event: K, callback: SimliClientEvents[K]): void; | ||
@@ -74,0 +75,0 @@ off<K extends keyof SimliClientEvents>(event: K, callback: SimliClientEvents[K]): void; |
+24
-6
@@ -71,2 +71,3 @@ "use strict"; | ||
| this.inputIceServers = []; | ||
| this.config = null; | ||
| this.ClearBuffer = () => { | ||
@@ -113,2 +114,3 @@ var _a; | ||
| } | ||
| this.config = config; | ||
| this.apiKey = config.apiKey; | ||
@@ -141,3 +143,3 @@ this.faceID = config.faceID; | ||
| } | ||
| console.log("SIMLI: simli-client@1.2.8 initialized"); | ||
| console.log("SIMLI: simli-client@1.2.14 initialized"); | ||
| } | ||
@@ -269,2 +271,3 @@ else { | ||
| try { | ||
| await this.cleanup(); | ||
| this.clearTimeouts(); | ||
@@ -288,3 +291,5 @@ // Set overall connection timeout | ||
| // Get All POST request related data at the same time | ||
| const sessionRunData = await Promise.all([this.getIceServers(this.apiKey, this.SimliURL), this.createSessionToken(this.SimliURL, metadata), | ||
| const sessionRunData = await Promise.all([ | ||
| this.getIceServers(this.apiKey, this.SimliURL), | ||
| this.createSessionToken(this.SimliURL, metadata), | ||
| ]); | ||
@@ -442,2 +447,3 @@ iceServers = sessionRunData[0]; | ||
| let timeoutId; | ||
| this.answer = null; | ||
| await Promise.race([ | ||
@@ -469,2 +475,4 @@ new Promise((resolve, reject) => { | ||
| return; | ||
| this.candidateCount = 0; | ||
| this.prevCandidateCount = 0; | ||
| if (this.pc.iceGatheringState === "complete") { | ||
@@ -516,5 +524,2 @@ return; | ||
| async cleanup() { | ||
| this.clearTimeouts(); | ||
| this.stopDataChannelInterval(); | ||
| this.events.clear(); | ||
| if (this.webSocket) { | ||
@@ -543,3 +548,16 @@ this.webSocket.close(); | ||
| this.prevCandidateCount = -1; | ||
| this.errorReason = null; | ||
| this.videoRef = null; | ||
| this.audioRef = null; | ||
| this.answer = null; | ||
| this.localDescription = null; | ||
| this.pingSendTimes = new Map(); | ||
| // Event handling | ||
| this.retryAttempt = 1; | ||
| this.inputIceServers = []; | ||
| this.clearTimeouts(); | ||
| this.stopDataChannelInterval(); | ||
| this.answer = null; | ||
| if (this.config) { | ||
| this.Initialize(this.config); | ||
| } | ||
| } | ||
@@ -546,0 +564,0 @@ clearTimeouts() { |
+31
-11
@@ -109,2 +109,3 @@ // src/index.ts | ||
| private inputIceServers: RTCIceServer[] = []; | ||
| public config: SimliClientConfig | null = null; | ||
@@ -143,3 +144,3 @@ // Type-safe event methods | ||
| } | ||
| this.config = config; | ||
| this.apiKey = config.apiKey; | ||
@@ -172,3 +173,3 @@ this.faceID = config.faceID; | ||
| } | ||
| console.log("SIMLI: simli-client@1.2.8 initialized"); | ||
| console.log("SIMLI: simli-client@1.2.14 initialized"); | ||
| } else { | ||
@@ -306,2 +307,3 @@ console.warn( | ||
| try { | ||
| await this.cleanup() | ||
| this.clearTimeouts(); | ||
@@ -327,6 +329,8 @@ // Set overall connection timeout | ||
| // Get All POST request related data at the same time | ||
| const sessionRunData = await Promise.all | ||
| ([this.getIceServers(this.apiKey, this.SimliURL), this.createSessionToken(this.SimliURL, metadata), | ||
| ]) | ||
| const sessionRunData = await Promise.all( | ||
| [ | ||
| this.getIceServers(this.apiKey, this.SimliURL), | ||
| this.createSessionToken(this.SimliURL, metadata), | ||
| ] | ||
| ) | ||
| iceServers = sessionRunData[0] | ||
@@ -496,2 +500,3 @@ this.session_token = sessionRunData[1].session_token | ||
| let timeoutId: NodeJS.Timeout; | ||
| this.answer = null | ||
| await Promise.race([ | ||
@@ -524,2 +529,4 @@ new Promise<void>((resolve, reject) => { | ||
| if (!this.pc) return; | ||
| this.candidateCount = 0; | ||
| this.prevCandidateCount = 0; | ||
@@ -576,6 +583,2 @@ if (this.pc.iceGatheringState === "complete") { | ||
| private async cleanup() { | ||
| this.clearTimeouts(); | ||
| this.stopDataChannelInterval(); | ||
| this.events.clear(); | ||
| if (this.webSocket) { | ||
@@ -609,3 +612,20 @@ this.webSocket.close(); | ||
| this.prevCandidateCount = -1; | ||
| this.errorReason = null; | ||
| this.videoRef = null; | ||
| this.audioRef = null; | ||
| this.answer = null; | ||
| this.localDescription = null; | ||
| this.pingSendTimes = new Map(); | ||
| // Event handling | ||
| this.retryAttempt = 1; | ||
| this.inputIceServers = []; | ||
| this.clearTimeouts(); | ||
| this.stopDataChannelInterval(); | ||
| this.answer = null | ||
| if (this.config) { | ||
| this.Initialize(this.config); | ||
| } | ||
| } | ||
@@ -612,0 +632,0 @@ |
+1
-1
| { | ||
| "name": "simli-client", | ||
| "version": "1.2.13", | ||
| "version": "1.2.14", | ||
| "description": "Simli WebRTC Client", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
71187
1.69%1665
2.34%