This is the template project that's checked out and configured when you run the bando-up command from ljsthw-bandolier. This is where the code really lives.
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.
 
 
 
 
bandolier-template/client/websocket.js

27 lines
538 B

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;
}