
socket.on('message', ({ data }) => {
	handle_new_message(data);
});

const handle_new_message = (message) => {
	const div_thread = document.getElementById('msg_thread');

	console.log("received message:");
	console.log(`[${message}]`);

	div_thread.appendChild(build_new_message(message));
}

const build_new_message = (message) => {
	const p = document.createElement("p");
	p.appendChild(document.createTextNode(message));
	return p;
}

