Socket
Socket
Sign inDemoInstall

@geckos.io/client

Package Overview
Dependencies
1
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.2 to 1.4.3

1

lib/client.d.ts

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

private url;
private bridge;
private receivedReliableMessages;

@@ -8,0 +9,0 @@ constructor(url: string, port: number, label: string, rtcConfiguration: RTCConfiguration);

22

lib/client.js

@@ -43,3 +43,2 @@ "use strict";

exports.ClientChannel = void 0;
var bridge_1 = __importDefault(require("@geckos.io/common/lib/bridge"));
var reliableMessage_1 = require("@geckos.io/common/lib/reliableMessage");

@@ -51,2 +50,3 @@ var constants_1 = require("@geckos.io/common/lib/constants");

function ClientChannel(url, port, label, rtcConfiguration) {
var _this = this;
// stores all reliable messages for about 15 seconds

@@ -56,8 +56,12 @@ this.receivedReliableMessages = [];

this.connectionsManager = new connectionsManager_1.default(this.url, label, rtcConfiguration);
this.bridge = this.connectionsManager.bridge;
// remove all event listeners on disconnect
this.bridge.on(constants_1.EVENTS.DISCONNECTED, function () { return _this.bridge.removeAllListeners(); });
}
ClientChannel.prototype.onconnectionstatechange = function () {
var _this = this;
var lpc = this.peerConnection.localPeerConnection;
lpc.onconnectionstatechange = function () {
if (lpc.connectionState === 'disconnected' || lpc.connectionState === 'closed')
bridge_1.default.emit(constants_1.EVENTS.DISCONNECTED);
_this.bridge.emit(constants_1.EVENTS.DISCONNECTED);
};

@@ -77,3 +81,3 @@ };

// fire the DISCONNECTED event manually
bridge_1.default.emit(constants_1.EVENTS.DISCONNECTED);
this.bridge.emit(constants_1.EVENTS.DISCONNECTED);
try {

@@ -129,3 +133,3 @@ var host = this.url + "/.wrtc/v1";

ClientChannel.prototype.onRaw = function (callback) {
bridge_1.default.on(constants_1.EVENTS.RAW_MESSAGE, function (rawMessage) {
this.bridge.on(constants_1.EVENTS.RAW_MESSAGE, function (rawMessage) {
var cb = function (rawMessage) { return callback(rawMessage); };

@@ -146,3 +150,3 @@ cb(rawMessage);

// TODO(yandeu) add a connection timeout (or something like this)
bridge_1.default.on(constants_1.EVENTS.DATA_CHANNEL_IS_OPEN, function () {
this.bridge.on(constants_1.EVENTS.DATA_CHANNEL_IS_OPEN, function () {
callback();

@@ -168,5 +172,3 @@ });

ClientChannel.prototype.onDisconnect = function (callback) {
bridge_1.default.on(constants_1.EVENTS.DISCONNECTED, callback);
// remove all event listeners
bridge_1.default.removeAllListeners();
this.bridge.on(constants_1.EVENTS.DISCONNECTED, callback);
};

@@ -180,6 +182,6 @@ /**

var _this = this;
bridge_1.default.on(eventName, function (data) {
this.bridge.on(eventName, function (data) {
// check if message is reliable
// and reject it if it has already been submitted
var isReliableMessage = data && typeof data.MESSAGE !== 'undefined' && data.RELIABLE === 1 && data.ID !== 'undefined';
var isReliableMessage = data && data.RELIABLE === 1 && data.ID !== 'undefined';
var expireTime = 15000; // 15 seconds

@@ -186,0 +188,0 @@ var deleteExpiredReliableMessages = function () {

@@ -0,1 +1,2 @@

import { Bridge } from '@geckos.io/common/lib/bridge';
import { RawMessage, Data, ChannelId, EventName } from '@geckos.io/common/lib/typings';

@@ -14,2 +15,3 @@ interface RTCRemotePeerConnection {

id: ChannelId;
bridge: Bridge;
emit(eventName: EventName, data?: Data | RawMessage | null): void;

@@ -16,0 +18,0 @@ constructor(url: string, label: string, rtcConfiguration: RTCConfiguration);

@@ -53,3 +53,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var bridge_1 = __importDefault(require("@geckos.io/common/lib/bridge"));
var bridge_1 = require("@geckos.io/common/lib/bridge");
var constants_1 = require("@geckos.io/common/lib/constants");

@@ -64,2 +64,3 @@ var parseMessage_1 = __importDefault(require("@geckos.io/common/lib/parseMessage"));

this.rtcConfiguration = rtcConfiguration;
this.bridge = new bridge_1.Bridge();
this.onDataChannel = function (ev) {

@@ -75,5 +76,5 @@ var channel = ev.channel;

var _a = parseMessage_1.default(ev), key = _a.key, data = _a.data;
bridge_1.default.emit(key, data);
_this.bridge.emit(key, data);
};
bridge_1.default.emit(constants_1.EVENTS.DATA_CHANNEL_IS_OPEN);
_this.bridge.emit(constants_1.EVENTS.DATA_CHANNEL_IS_OPEN);
};

@@ -80,0 +81,0 @@ }

{
"name": "@geckos.io/client",
"version": "1.4.2",
"version": "1.4.3",
"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.4.2"
"@geckos.io/common": "^1.4.3"
}
}

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc