Socket
Socket
Sign inDemoInstall

@geckos.io/client

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@geckos.io/client - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

2

lib/client.d.ts

@@ -11,2 +11,4 @@ import { RawMessage, Data, EventName, EventCallbackClient, ConnectionEventCallbackClient, EventCallbackRawMessage, ClientOptions, EmitOptions } from '@geckos.io/common/lib/typings';

get id(): import("../../common/lib/typings").ChannelId;
/** Close the WebRTC connection */
close(): void;
/** Emit a message to the server. */

@@ -13,0 +15,0 @@ emit(eventName: EventName, data?: Data | null, options?: EmitOptions): void;

@@ -69,2 +69,20 @@ "use strict";

});
/** Close the WebRTC connection */
ClientChannel.prototype.close = function () {
this.peerConnection.localPeerConnection.close();
// fire the DISCONNECTED event manually
bridge_1.default.emit(constants_1.EVENTS.DISCONNECTED);
try {
var host = this.url + "/.wrtc/v1";
fetch(host + "/connections/" + this.id + "/close", {
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
});
}
catch (error) {
console.error(error.message);
}
};
/** Emit a message to the server. */

@@ -71,0 +89,0 @@ ClientChannel.prototype.emit = function (eventName, data, options) {

@@ -17,2 +17,3 @@ import { RawMessage, Data, ChannelId, EventName } from '@geckos.io/common/lib/typings';

onDataChannel: (ev: RTCDataChannelEvent) => void;
fetchAdditionalCandidates(host: string, id: ChannelId): Promise<void>;
connect(): Promise<{

@@ -19,0 +20,0 @@ localPeerConnection: RTCPeerConnection;

@@ -82,5 +82,34 @@ "use strict";

};
// fetch additional candidates
ConnectionsManagerClient.prototype.fetchAdditionalCandidates = function (host, id) {
return __awaiter(this, void 0, void 0, function () {
var res, candidates;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, fetch(host + "/connections/" + id + "/additional-candidates", {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
})];
case 1:
res = _a.sent();
if (!res.ok) return [3 /*break*/, 3];
return [4 /*yield*/, res.json()];
case 2:
candidates = _a.sent();
candidates.forEach(function (c) {
_this.localPeerConnection.addIceCandidate(c);
});
_a.label = 3;
case 3: return [2 /*return*/];
}
});
});
};
ConnectionsManagerClient.prototype.connect = function () {
return __awaiter(this, void 0, void 0, function () {
var host, res, _a, error_1, _b, id, localDescription, configuration, RTCPc, originalAnswer, updatedAnswer, error_2, error_3;
var host, res, _a, error_1, _b, id, localDescription, configuration, RTCPc, showBackOffIntervals, originalAnswer, updatedAnswer, error_2, error_3;
var _this = this;
return __generator(this, function (_c) {

@@ -119,3 +148,18 @@ switch (_c.label) {

mozRTCPeerConnection;
// create rtc peer connection
this.localPeerConnection = new RTCPc(configuration);
showBackOffIntervals = function (attempts, initial, factor, jitter) {
if (attempts === void 0) { attempts = 10; }
if (initial === void 0) { initial = 50; }
if (factor === void 0) { factor = 1.8; }
if (jitter === void 0) { jitter = 20; }
return Array(attempts)
.fill(0)
.map(function (_, index) { return parseInt((initial * Math.pow(factor, index)).toString()) + parseInt((Math.random() * jitter).toString()); });
};
showBackOffIntervals().forEach(function (ms) {
setTimeout(function () {
_this.fetchAdditionalCandidates(host, id);
}, ms);
});
_c.label = 6;

@@ -122,0 +166,0 @@ case 6:

4

package.json
{
"name": "@geckos.io/client",
"version": "1.3.0",
"version": "1.4.0",
"description": "Real-time client/server communication over UDP using WebRTC and Node.js",

@@ -47,4 +47,4 @@ "main": "lib/index.js",

"dependencies": {
"@geckos.io/common": "^1.3.0"
"@geckos.io/common": "^1.4.0"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc