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.
28 lines
538 B
28 lines
538 B
2 years ago
|
import { inject_remote } from "$/client/components/Source.svelte";
|
||
|
|
||
|
let raw_socket;
|
||
|
|
||
|
export const configure_socket = async () => {
|
||
|
await inject_remote(document, "/js/socket.io.min.js");
|
||
|
}
|
||
|
|
||
|
|
||
|
export const connect_socket = (reconnection=false) => {
|
||
|
if(raw_socket === undefined) {
|
||
|
raw_socket = io({ reconnection });
|
||
|
}
|
||
|
|
||
|
return raw_socket;
|
||
|
}
|
||
|
|
||
|
export const reconnect_socket = () => {
|
||
|
if(raw_socket !== undefined) {
|
||
|
raw_socket.disconnect();
|
||
|
raw_socket.connect();
|
||
|
} else {
|
||
|
connect_socket();
|
||
|
}
|
||
|
|
||
|
return raw_socket;
|
||
|
}
|