mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-17 16:10:02 -04:00
add better clarification on websocket payload conversion
This commit is contained in:
parent
2760770b3d
commit
baa9884d5d
1 changed files with 2 additions and 0 deletions
|
@ -70,12 +70,14 @@ export default function (client: ScramjetClient, self: typeof globalThis) {
|
||||||
if (typeof payload === "string") {
|
if (typeof payload === "string") {
|
||||||
// DO NOTHING
|
// DO NOTHING
|
||||||
} else if ("byteLength" in payload) {
|
} else if ("byteLength" in payload) {
|
||||||
|
// arraybuffer, convert to blob if needed or set the proper prototype
|
||||||
if (state.binaryType === "blob") {
|
if (state.binaryType === "blob") {
|
||||||
payload = new Blob([payload]);
|
payload = new Blob([payload]);
|
||||||
} else {
|
} else {
|
||||||
Object.setPrototypeOf(payload, ArrayBuffer.prototype);
|
Object.setPrototypeOf(payload, ArrayBuffer.prototype);
|
||||||
}
|
}
|
||||||
} else if ("arrayBuffer" in payload) {
|
} else if ("arrayBuffer" in payload) {
|
||||||
|
// blob, convert to arraybuffer if neccesary.
|
||||||
if (state.binaryType === "arraybuffer") {
|
if (state.binaryType === "arraybuffer") {
|
||||||
payload = await payload.arrayBuffer();
|
payload = await payload.arrayBuffer();
|
||||||
Object.setPrototypeOf(payload, ArrayBuffer.prototype);
|
Object.setPrototypeOf(payload, ArrayBuffer.prototype);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue