mirror of
https://github.com/torappinfo/uweb.git
synced 2024-08-14 23:54:59 +00:00
14 lines
408 B
JavaScript
14 lines
408 B
JavaScript
|
window.WebSocketOriginal = window.WebSocket;
|
||
|
(function () {
|
||
|
function CustomWebSocket(url) {
|
||
|
const ws = new window.WebSocketOriginal(url);
|
||
|
Object.getOwnPropertyNames(window.WebSocket.prototype).forEach(methodName => {
|
||
|
if (methodName !== 'constructor') {
|
||
|
CustomWebSocket.prototype[methodName] = ws[methodName].bind(ws);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
window.WebSocket = CustomWebSocket;
|
||
|
})();
|
||
|
t
|