@geckos.io/client
Advanced tools
Comparing version 1.3.0-alpha.0 to 1.3.0
@@ -49,3 +49,3 @@ "use strict"; | ||
function ClientChannel(url, port, label, rtcConfiguration) { | ||
// TODO (yandeu): remove old messages from this.receivedReliableMessages | ||
// stores all reliable messages for about 15 seconds | ||
this.receivedReliableMessages = []; | ||
@@ -157,5 +157,19 @@ this.url = url + ":" + port; | ||
var isReliableMessage = data && typeof data.MESSAGE !== 'undefined' && data.RELIABLE === 1 && data.ID !== 'undefined'; | ||
var expireTime = 15000; // 15 seconds | ||
var deleteExpiredReliableMessages = function () { | ||
var currentTime = new Date().getTime(); | ||
_this.receivedReliableMessages.forEach(function (msg, index, object) { | ||
if (msg.expire <= currentTime) { | ||
object.splice(index, 1); | ||
} | ||
}); | ||
}; | ||
if (isReliableMessage) { | ||
deleteExpiredReliableMessages(); | ||
if (_this.receivedReliableMessages.filter(function (obj) { return obj.id === data.ID; }).length === 0) { | ||
_this.receivedReliableMessages.push({ date: new Date(), id: data.ID }); | ||
_this.receivedReliableMessages.push({ | ||
id: data.ID, | ||
timestamp: new Date(), | ||
expire: new Date().getTime() + expireTime | ||
}); | ||
callback(data.MESSAGE); | ||
@@ -162,0 +176,0 @@ } |
{ | ||
"name": "@geckos.io/client", | ||
"version": "1.3.0-alpha.0", | ||
"version": "1.3.0", | ||
"description": "Real-time client/server communication over UDP using WebRTC and Node.js", | ||
@@ -37,3 +37,3 @@ "main": "lib/index.js", | ||
"engines": { | ||
"node": "^8 || ^10 || ^11 || ^12" | ||
"node": "^8 || ^10 || ^11 || ^12 || ^13" | ||
}, | ||
@@ -48,4 +48,4 @@ "scripts": { | ||
"dependencies": { | ||
"@geckos.io/common": "^1.3.0-alpha.0" | ||
"@geckos.io/common": "^1.3.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
40770
550
0
Updated@geckos.io/common@^1.3.0