websocket.js 408 B

1234567891011121314
  1. window.WebSocketOriginal = window.WebSocket;
  2. (function () {
  3. function CustomWebSocket(url) {
  4. const ws = new window.WebSocketOriginal(url);
  5. Object.getOwnPropertyNames(window.WebSocket.prototype).forEach(methodName => {
  6. if (methodName !== 'constructor') {
  7. CustomWebSocket.prototype[methodName] = ws[methodName].bind(ws);
  8. }
  9. });
  10. }
  11. window.WebSocket = CustomWebSocket;
  12. })();
  13. t