thelounge/client/js/socket.ts

22 lines
499 B
TypeScript
Raw Normal View History

import io, {Socket} from "socket.io-client";
2017-04-18 09:31:46 +02:00
2022-05-15 00:18:06 +02:00
const socket: Socket = io({
transports: JSON.parse(document.body.dataset.transports || "['polling', 'websocket']"),
path: window.location.pathname + "socket.io/",
2017-04-18 09:31:46 +02:00
autoConnect: false,
reconnection: !document.body.classList.contains("public"),
2017-04-18 09:31:46 +02:00
});
// Ease debugging socket during development
if (process.env.NODE_ENV === "development") {
window.socket = socket;
}
declare global {
interface Window {
socket: Socket;
}
}
2019-11-16 18:24:03 +01:00
export default socket;