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.2.0 to 1.3.0-alpha.0

5

lib/client.d.ts

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

import { RawMessage, Data, EventName, EventCallbackClient, ConnectionEventCallbackClient, EventCallbackRawMessage, ClientOptions } from '@geckos.io/common/lib/typings';
import { RawMessage, Data, EventName, EventCallbackClient, ConnectionEventCallbackClient, EventCallbackRawMessage, ClientOptions, EmitOptions } from '@geckos.io/common/lib/typings';
export declare class ClientChannel {

@@ -6,2 +6,3 @@ private peerConnection;

private url;
private receivedReliableMessages;
constructor(url: string, port: number, label: string, rtcConfiguration: RTCConfiguration);

@@ -12,3 +13,3 @@ private onconnectionstatechange;

/** Emit a message to the server. */
emit(eventName: EventName, data?: Data | null): void;
emit(eventName: EventName, data?: Data | null, options?: EmitOptions): void;
/** Emit a raw message to the server */

@@ -15,0 +16,0 @@ get raw(): {

36

lib/client.js

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

var bridge_1 = __importDefault(require("@geckos.io/common/lib/bridge"));
var reliableMessage_1 = require("@geckos.io/common/lib/reliableMessage");
var constants_1 = require("@geckos.io/common/lib/constants");

@@ -49,2 +50,4 @@ var peerConnection_1 = __importDefault(require("./wrtc/peerConnection"));

function ClientChannel(url, port, label, rtcConfiguration) {
// TODO (yandeu): remove old messages from this.receivedReliableMessages
this.receivedReliableMessages = [];
this.url = url + ":" + port;

@@ -69,5 +72,17 @@ this.connectionsManager = new connectionsManager_1.default(this.url, label, rtcConfiguration);

/** Emit a message to the server. */
ClientChannel.prototype.emit = function (eventName, data) {
ClientChannel.prototype.emit = function (eventName, data, options) {
var _this = this;
if (data === void 0) { data = null; }
this.connectionsManager.emit(eventName, data);
if (options && options.reliable) {
reliableMessage_1.makeReliable(options, function (id) {
return _this.connectionsManager.emit(eventName, {
MESSAGE: data,
RELIABLE: 1,
ID: id
});
});
}
else {
this.connectionsManager.emit(eventName, data);
}
};

@@ -139,4 +154,19 @@ Object.defineProperty(ClientChannel.prototype, "raw", {

ClientChannel.prototype.on = function (eventName, callback) {
var _this = this;
bridge_1.default.on(eventName, function (data) {
callback(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';
if (isReliableMessage) {
if (_this.receivedReliableMessages.filter(function (obj) { return obj.id === data.ID; }).length === 0) {
_this.receivedReliableMessages.push({ date: new Date(), id: data.ID });
callback(data.MESSAGE);
}
else {
// reject message
}
}
else {
callback(data);
}
});

@@ -143,0 +173,0 @@ };

{
"name": "@geckos.io/client",
"version": "1.2.0",
"version": "1.3.0-alpha.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.2.0"
"@geckos.io/common": "^1.3.0-alpha.0"
}
}

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