mirror of
https://github.com/thelounge/thelounge.git
synced 2024-05-17 21:56:36 +02:00
22 lines
499 B
TypeScript
22 lines
499 B
TypeScript
import io, {Socket} from "socket.io-client";
|
|
|
|
const socket: Socket = io({
|
|
transports: JSON.parse(document.body.dataset.transports || "['polling', 'websocket']"),
|
|
path: window.location.pathname + "socket.io/",
|
|
autoConnect: false,
|
|
reconnection: !document.body.classList.contains("public"),
|
|
});
|
|
|
|
// Ease debugging socket during development
|
|
if (process.env.NODE_ENV === "development") {
|
|
window.socket = socket;
|
|
}
|
|
|
|
declare global {
|
|
interface Window {
|
|
socket: Socket;
|
|
}
|
|
}
|
|
|
|
export default socket;
|