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

@push-rpc/core

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@push-rpc/core - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

2

dist/index.d.ts

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

export { Topic, RpcContext, RpcConnectionContext, MessageType, Middleware, RemoteTopic, LocalTopic, } from "./rpc";
export { Topic, RpcContext, RpcConnectionContext, MessageType, Middleware, RemoteTopic, LocalTopic, DataSupplier, DataConsumer } from "./rpc";
export { Socket, SocketServer } from "./transport";

@@ -3,0 +3,0 @@ export { LocalTopicImpl } from "./local";

@@ -22,2 +22,3 @@ import { DataConsumer, DataSupplier, Topic, TopicImpl } from "./rpc";

private subscriptions;
isSubscribed(): boolean;
get(params?: F): Promise<D>;

@@ -24,0 +25,0 @@ subscribe(consumer: DataConsumer<D>, params: F, subscriptionKey: any): void;

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

this.subscriptions[key] = subscription;
if (!this.supplier) return [3 /*break*/, 2];
return [4 /*yield*/, this.supplier(filter, session.createContext())];

@@ -166,4 +165,3 @@ case 1:

session.send(rpc_1.MessageType.Data, utils_1.createMessageId(), this.name, filter, data);
_a.label = 2;
case 2: return [2 /*return*/];
return [2 /*return*/];
}

@@ -184,2 +182,5 @@ });

};
LocalTopicImpl.prototype.isSubscribed = function () {
return !!this.subscriptions.length;
};
// dummy implementations, see class comment

@@ -186,0 +187,0 @@ LocalTopicImpl.prototype.get = function (params) {

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

exports.mapTopic = mapTopic;
// TODO better name would be createDomSocket
function createDomWebsocket(url, protocols) {

@@ -167,0 +168,0 @@ if (protocols === void 0) { protocols = undefined; }

{
"name": "@push-rpc/core",
"version": "1.1.2",
"version": "1.1.3",
"main": "dist/index.js",

@@ -20,3 +20,3 @@ "types": "dist/index.d.ts",

},
"gitHead": "4907513edf8ccc166e61d84e6f6076fff66f689a"
"gitHead": "8c3531b9c19952ac22c846688f45cb22f9ace5bd"
}

@@ -9,2 +9,4 @@ export {

LocalTopic,
DataSupplier,
DataConsumer
} from "./rpc"

@@ -11,0 +13,0 @@ export {Socket, SocketServer} from "./transport"

@@ -82,6 +82,4 @@ import {DataConsumer, DataSupplier, MessageType, Topic, TopicImpl} from "./rpc"

if (this.supplier) {
const data = await this.supplier(filter, session.createContext())
session.send(MessageType.Data, createMessageId(), this.name, filter, data)
}
const data = await this.supplier(filter, session.createContext())
session.send(MessageType.Data, createMessageId(), this.name, filter, data)
}

@@ -105,2 +103,6 @@

isSubscribed(): boolean {
return !!this.subscriptions.length
}
// dummy implementations, see class comment

@@ -107,0 +109,0 @@

@@ -122,3 +122,3 @@ import * as UUID from "uuid-js"

// TODO better name would be createDomSocket
export function createDomWebsocket(url, protocols = undefined) {

@@ -125,0 +125,0 @@ const ws = new WebSocket(url, protocols)

@@ -34,2 +34,75 @@ import {createTestClient, startTestServer} from "./testUtils"

it("handle unsynced clients", async () => {
let resolveServerCall
let resolveClientCall
let clientResponse
let serverResponse
const rpcServer = await startTestServer({
callServer() {
console.log("Server called")
return new Promise(resolve => {
resolveServerCall = resolve
})
},
}, {
syncRemoteCalls: true,
listeners: {
connected: (id, total) => {
setTimeout(async () => {
const client = await rpcServer.getRemote(id)
console.log("Try to call client")
clientResponse = await client.callClient()
}, 100)
},
disconnected: (id, total) => {
},
messageIn: (remoteId, data) => {
console.log("IN", data)
},
messageOut: (remoteId, data) => {
console.log("OUT", data)
},
subscribed: () => {
},
unsubscribed: () => {
},
}
})
const client = {
callClient() {
console.log("Client called")
return new Promise(resolve => {
resolveClientCall = resolve
})
}
}
const server = await createTestClient(0, {local: client})
// wait for server to call client
await new Promise(r => setTimeout(r, 200))
// client call is not resolved yet.
// but let client make his call to server
server.callServer().then(r => {
serverResponse = r
})
// and immediately respond
resolveClientCall("client ok")
await new Promise(r => setTimeout(r, 100))
resolveServerCall("server ok")
// give some time to complete all cbs
await new Promise(r => setTimeout(r, 50))
// make sure all have responded with correct values
assert.equal(serverResponse, "server ok")
assert.equal(clientResponse, "client ok")
})
false &&

@@ -36,0 +109,0 @@ it("wait local answer before calling remote", async () => {

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