import AbstractView from "./AbstractView.js"; export default class extends AbstractView { constructor(params) { super(params, "Chat"); let url = `ws://${window.location.host}/ws/chat/` this.chatSocket = new WebSocket(url) this.chatSocket.onmessage = function(e){ let data = JSON.parse(e.data) console.log('Data:', data) if (data.type === 'chat') { let messages = document.getElementById('messages') let username = data.username === null || data.username.length <= 0 ? "NoName" : data.username; messages.insertAdjacentHTML('beforeend', `
${username}: ${data.message}