web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
768 B

  1. const SockJS = require('sockjs-client/dist/sockjs');
  2. const safeThis = require('./utils/safeThis');
  3. /**
  4. * A SockJS client adapted for use with webpack-dev-server.
  5. * @constructor
  6. * @param {string} url The socket URL.
  7. */
  8. function SockJSClient(url) {
  9. this.socket = new SockJS(url);
  10. }
  11. /**
  12. * Creates a handler to handle socket close events.
  13. * @param {function(): void} fn
  14. */
  15. SockJSClient.prototype.onClose = function onClose(fn) {
  16. this.socket.onclose = fn;
  17. };
  18. /**
  19. * Creates a handler to handle socket message events.
  20. * @param {function(*): void} fn
  21. */
  22. SockJSClient.prototype.onMessage = function onMessage(fn) {
  23. this.socket.onmessage = function onMessageHandler(event) {
  24. fn(event.data);
  25. };
  26. };
  27. safeThis.__webpack_dev_server_client__ = SockJSClient;