Skip to content
Snippets Groups Projects
script.js 627 B
Newer Older
import SignalingServerConnection from "./SignalingServerConnection.js";

document.addEventListener("DOMContentLoaded",async()=>{
	const signaler = new SignalingServerConnection();
	if (document.location.hash){
		document.body.innerHTML = "";
		await signaler.join(document.location.hash.substring(1));
	}else{
		/** @type {HTMLButtonElement} *///@ts-ignore
		const button = document.getElementById("button");
		console.log(signaler);
		button.addEventListener("click",async e=>{
			button.disabled = true;
			let id = await signaler.host(()=>{});
			alert(document.location.host+document.location.pathname+"#"+id);
		});
	}