@push-rpc/websocket
Advanced tools
Comparing version 1.6.0 to 1.6.1
@@ -36,5 +36,16 @@ "use strict"; | ||
var errorHandler = function () { }; | ||
var messageReplay = []; | ||
ws.on("message", function (e) { | ||
if (messageReplay) { | ||
messageReplay.push(e.toString("utf-8")); | ||
} | ||
}); | ||
return { | ||
onMessage: function (h) { | ||
return ws.on("message", function (e) { | ||
for (var _i = 0, messageReplay_1 = messageReplay; _i < messageReplay_1.length; _i++) { | ||
var message = messageReplay_1[_i]; | ||
h(message); | ||
} | ||
messageReplay = null; | ||
ws.on("message", function (e) { | ||
h(e.toString("utf-8")); | ||
@@ -41,0 +52,0 @@ }); |
{ | ||
"name": "@push-rpc/websocket", | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"main": "dist/index.js", | ||
@@ -12,3 +12,3 @@ "types": "dist/index.d.ts", | ||
"dependencies": { | ||
"@push-rpc/core": "^1.6.0", | ||
"@push-rpc/core": "^1.6.1", | ||
"ws": "^7.2.0" | ||
@@ -21,3 +21,3 @@ }, | ||
}, | ||
"gitHead": "193290f9397e577b92f9087b5a359126ddf7d02c" | ||
"gitHead": "c0d75bc93b480a01668e03dc0d1d5909d06999ca" | ||
} |
@@ -38,7 +38,22 @@ import * as WebSocket from "ws" | ||
let messageReplay = [] | ||
ws.on("message", e => { | ||
if (messageReplay) { | ||
messageReplay.push(e.toString("utf-8")) | ||
} | ||
}) | ||
return { | ||
onMessage: h => | ||
onMessage: h => { | ||
for (const message of messageReplay) { | ||
h(message) | ||
} | ||
messageReplay = null | ||
ws.on("message", e => { | ||
h(e.toString("utf-8")) | ||
}), | ||
}) | ||
}, | ||
onOpen: h => ws.on("open", h), | ||
@@ -45,0 +60,0 @@ onDisconnected: h => |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8857
234
Updated@push-rpc/core@^1.6.1