Archived
1
0

First commit

This commit is contained in:
Sean Edmunds
2021-12-13 17:00:40 -06:00
commit 0584430b5c
36617 changed files with 4676695 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
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;