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

@cap-js-community/websocket

Package Overview
Dependencies
Maintainers
7
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cap-js-community/websocket - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

8

CHANGELOG.md

@@ -8,2 +8,8 @@ # Changelog

## Version 0.5.1 - 2024-01-31
### Fixed
- Fix message wrapping for Redis distribution (`kind: ws`)
## Version 0.5.0 - 2024-01-29

@@ -36,2 +42,4 @@

npm
### Added

@@ -38,0 +46,0 @@

2

package.json
{
"name": "@cap-js-community/websocket",
"version": "0.5.0",
"version": "0.6.0",
"description": "WebSocket adapter for CDS",

@@ -5,0 +5,0 @@ "homepage": "https://cap.cloud.sap/",

@@ -115,3 +115,4 @@ # @cap-js-community/websocket

- Broadcast CDS events across multiple CAP server applications and application instances (via Redis)
- Emit/Broadcast CDS events from server websockets to websocket clients (browser and non-browser)
- Tenant-ware emit/broadcast CDS events from server websockets to websocket clients (browser and non-browser)
- Emit/Broadcast CDS events to a subset of websocket clients leveraging event contexts

@@ -118,0 +119,0 @@ ### WebSocket Server

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

* @param {string} service service path, e.g. "/chat"
* @param {function<object>} connected Callback function to be called on every websocket connection passing socket functions (i.e. ws.on("connection", connected)) passing the facade
* @param {function} connected Callback function to be called on every websocket connection passing socket facade (i.e. ws.on("connection", connected))
*/

@@ -37,0 +37,0 @@ service(service, connected) {

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

service(service, connected) {
const io = this.applyMiddleware(this.io.of(service));
const io = this.applyMiddlewares(this.io.of(service));
io.on("connection", async (socket) => {

@@ -155,3 +155,3 @@ try {

applyMiddleware(io) {
applyMiddlewares(io) {
for (const middleware of this.middlewares()) {

@@ -158,0 +158,0 @@ io.use(middleware);

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

});
this.applyMiddleware(ws, async () => {
this.applyMiddlewares(ws, async () => {
try {

@@ -131,3 +131,4 @@ ws.tenant = ws.request.tenant;

async broadcast({ service, event, data, tenant, contexts, socket, remote }) {
if (!data) {
const eventMessage = !data;
if (eventMessage) {
const message = JSON.parse(event);

@@ -155,3 +156,3 @@ data = message.data;

if (clients.length > 0 || remote) {
const message = !data ? event : JSON.stringify({ event, data, tenant, contexts });
const message = eventMessage ? event : JSON.stringify({ event, data, tenant, contexts });
for (const client of clients) {

@@ -193,17 +194,21 @@ await client.send(message);

applyMiddleware(ws, next) {
applyMiddlewares(ws, next) {
const middlewares = this._middlewares.slice(0);
function call() {
const middleware = middlewares.shift();
if (!middleware) {
return next(null);
try {
const middleware = middlewares.shift();
if (!middleware) {
return next(null);
}
middleware(ws, (err) => {
if (err) {
next(err);
} else {
call();
}
});
} catch (err) {
next(err);
}
middleware(ws, (err) => {
if (err) {
next(err);
} else {
call();
}
});
}

@@ -210,0 +215,0 @@

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