socket.io-adapter
Advanced tools
Comparing version 2.5.0 to 2.5.1
"use strict"; | ||
var _a; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -6,3 +7,4 @@ exports.SessionAwareAdapter = exports.Adapter = void 0; | ||
const yeast_1 = require("./contrib/yeast"); | ||
const ws_1 = require("ws"); | ||
const WebSocket = require("ws"); | ||
const canPreComputeFrame = typeof ((_a = WebSocket === null || WebSocket === void 0 ? void 0 : WebSocket.Sender) === null || _a === void 0 ? void 0 : _a.frame) === "function"; | ||
class Adapter extends events_1.EventEmitter { | ||
@@ -167,7 +169,9 @@ /** | ||
const encodedPackets = this.encoder.encode(packet); | ||
if (encodedPackets.length === 1 && typeof encodedPackets[0] === "string") { | ||
if (canPreComputeFrame && | ||
encodedPackets.length === 1 && | ||
typeof encodedPackets[0] === "string") { | ||
// "4" being the "message" packet type in the Engine.IO protocol | ||
const data = Buffer.from("4" + encodedPackets[0]); | ||
// see https://github.com/websockets/ws/issues/617#issuecomment-283002469 | ||
packetOpts.wsPreEncodedFrame = ws_1.WebSocket.Sender.frame(data, { | ||
packetOpts.wsPreEncodedFrame = WebSocket.Sender.frame(data, { | ||
readOnly: false, | ||
@@ -174,0 +178,0 @@ mask: false, |
{ | ||
"name": "socket.io-adapter", | ||
"version": "2.5.0", | ||
"version": "2.5.1", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "repository": { |
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
23446
651