Skip to content

Commit

Permalink
add support for drain event and send response boolean to make sockjs …
Browse files Browse the repository at this point in the history
…compliant with Writeable api that allows for handling back pressure
  • Loading branch information
avistramer committed Nov 1, 2024
1 parent 0e8d891 commit efea906
Show file tree
Hide file tree
Showing 11 changed files with 940 additions and 1,075 deletions.
688 changes: 314 additions & 374 deletions dist/sockjs-esm.js

Large diffs are not rendered by default.

1,301 changes: 611 additions & 690 deletions dist/sockjs.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/sockjs.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/sockjs.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/sockjs.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ SockJS.prototype.send = function(data) {
if (this.readyState !== SockJS.OPEN) {
return;
}
this._transport.send(escape.quote(data));
return this._transport.send(escape.quote(data));
};

SockJS.version = require('./version');
Expand Down
1 change: 1 addition & 0 deletions lib/transport/iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ IframeTransport.prototype.postMessage = function(type, data) {
IframeTransport.prototype.send = function(message) {
debug('send', message);
this.postMessage('m', message);
return true;
};

IframeTransport.enabled = function() {
Expand Down
1 change: 1 addition & 0 deletions lib/transport/lib/buffered-sender.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ BufferedSender.prototype.send = function(message) {
if (!this.sendStop) {
this.sendSchedule();
}
return true;
};

// For polling transports in a situation when in the message callback,
Expand Down
5 changes: 4 additions & 1 deletion lib/transport/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,17 @@ function WebSocketTransport(transUrl, ignore, options) {
self.emit('close', 1006, 'WebSocket connection broken');
self._cleanup();
};
this.ws.on('drain', function() {
self.emit('drain');
})
}

inherits(WebSocketTransport, EventEmitter);

WebSocketTransport.prototype.send = function(data) {
var msg = '[' + data + ']';
debug('send', msg);
this.ws.send(msg);
return this.ws.send(msg);
};

WebSocketTransport.prototype.close = function() {
Expand Down
2 changes: 1 addition & 1 deletion lib/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = '1.6.2';
module.exports = '0.0.3';
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"name": "sockjs-client",
"name": "sockjs-client-testable",
"description": "SockJS-client is a browser JavaScript library that provides a WebSocket-like object.",
"version": "1.6.2",
"version": "0.0.4",
"author": "Bryce Kahle",
"jsdelivr": "dist/sockjs.min.js",
"engines": {
"node": ">=12"
},
"funding": "https://tidelift.com/funding/github/npm/sockjs-client",
"browser": {
"./lib/transport/driver/websocket.js": "./lib/transport/browser/websocket.js",
"eventsource": "./lib/transport/browser/eventsource.js",
Expand Down Expand Up @@ -70,7 +69,7 @@
"types": "./dist/sockjs.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/sockjs/sockjs-client.git"
"url": "https://github.com/testable/sockjs-client.git"
},
"scripts": {
"test": "mocha tests/node.js",
Expand Down

0 comments on commit efea906

Please sign in to comment.