@schukai/monster
Version:
Monster is a simple library for creating fast, robust and lightweight websites.
29 lines (19 loc) • 741 B
JavaScript
import {getGlobal} from "../../source/types/global.mjs";
function initWebSocket() {
// const isBrowser = typeof window === 'object' && '[object Window]' === window.toString.call(window)
const isNode = typeof global === 'object' && '[object global]' === global.toString.call(global)
if (!isNode) {
return Promise.resolve();
}
return import("ws").then((ws) => {
getGlobal().WebSocket = class extends ws['WebSocket'] {
constructor(url, protocols) {
super(url, protocols, {
handshakeTimeout: 1000,
maxPayload: 1024 * 1024 * 1024,
});
}
};
});
}
export {initWebSocket}