Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@creamery/socket.io-rpc

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@creamery/socket.io-rpc - npm Package Compare versions

Comparing version 1.0.9 to 1.0.10

lib/disposable.d.ts

5

lib/common.d.ts

@@ -30,1 +30,6 @@ /// <reference types="socket.io-client" />

}
export interface Disposable {
dispose(): void;
}
export declare function createDisposable(func: () => void): Disposable;
export declare function isDisposable(disposable: any): any;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function createDisposable(func) {
return {
dispose: func,
};
}
exports.createDisposable = createDisposable;
function isDisposable(disposable) {
return disposable && disposable.dispose;
}
exports.isDisposable = isDisposable;
//# sourceMappingURL=common.js.map

1

lib/index.js

@@ -6,4 +6,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./common"));
__export(require("./rpc-client"));
__export(require("./rpc-server"));
//# sourceMappingURL=index.js.map

2

lib/rpc-server.d.ts

@@ -26,3 +26,3 @@ import SocketIO from 'socket.io';

export declare class SocketIORPC {
private readonly pool;
private readonly vendors;
register(vendor: Vendor): void;

@@ -29,0 +29,0 @@ join(client: SocketIO.Socket): void;

@@ -7,2 +7,5 @@ "use strict";

const socket_io_1 = __importDefault(require("socket.io"));
const common_1 = require("./common");
const disposable_1 = require("./disposable");
const util_1 = require("util");
function createCallback({ seq, id, method }, client) {

@@ -17,4 +20,2 @@ function cb(...result) {

}
else {
}
}

@@ -56,8 +57,9 @@ return cb;

constructor() {
this.pool = new Map();
this.vendors = new Map();
}
register(vendor) {
this.pool.set(vendor.id, vendor);
this.vendors.set(vendor.id, vendor);
}
join(client) {
client.toDispose = new disposable_1.DisposableCollection();
client.on('call', (message, callback) => {

@@ -69,6 +71,10 @@ this.call(message, callback);

});
client.on('disconnect', () => {
const toDispose = client.toDispose;
toDispose.dispose();
});
}
notify(msg, client) {
const { id, channel, params, seq } = msg;
const vendor = this.pool.get(id);
const vendor = this.vendors.get(id);
if (!vendor) {

@@ -79,6 +85,10 @@ console.info('not found vendor', id);

const method = `on${channel}`;
if (typeof vendor[method] === 'function') {
if (util_1.isFunction(vendor[method])) {
try {
params.push(createCallback({ seq, id, method }, client));
vendor[method](...params);
const cb = createCallback({ seq, id, method }, client);
params.push(cb);
const disposable = vendor[method](...params);
if (common_1.isDisposable(disposable)) {
client.toDispose.push(disposable);
}
}

@@ -93,3 +103,3 @@ catch (err) {

const { id, method, params } = msg;
const vendor = this.pool.get(id);
const vendor = this.vendors.get(id);
if (!vendor) {

@@ -101,3 +111,3 @@ console.info('not found vendor', id);

const p = vendor[method](...params);
if (typeof p.then === 'function' && typeof p.catch === 'function') {
if (util_1.isFunction(p.then) && util_1.isFunction(p.catch)) {
p.then((result) => {

@@ -104,0 +114,0 @@ callback(SuccessResponse(id, method, result));

{
"name": "@creamery/socket.io-rpc",
"version": "1.0.9",
"version": "1.0.10",
"description": "RPC for SocketIO",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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