Archived
1
0
This repository has been archived on 2023-05-15. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
home-page/node_modules/@pmmmwh/react-refresh-webpack-plugin/client/LegacyWDSSocketEntry.js
Sean Edmunds 0584430b5c First commit
2021-12-13 17:00:40 -06:00

32 lines
768 B
JavaScript

const SockJS = require('sockjs-client/dist/sockjs');
const safeThis = require('./utils/safeThis');
/**
* A SockJS client adapted for use with webpack-dev-server.
* @constructor
* @param {string} url The socket URL.
*/
function SockJSClient(url) {
this.socket = new SockJS(url);
}
/**
* Creates a handler to handle socket close events.
* @param {function(): void} fn
*/
SockJSClient.prototype.onClose = function onClose(fn) {
this.socket.onclose = fn;
};
/**
* Creates a handler to handle socket message events.
* @param {function(*): void} fn
*/
SockJSClient.prototype.onMessage = function onMessage(fn) {
this.socket.onmessage = function onMessageHandler(event) {
fn(event.data);
};
};
safeThis.__webpack_dev_server_client__ = SockJSClient;