|
|
@ -1,8 +1,8 @@
|
|
|
|
<template>
|
|
|
|
<template>
|
|
|
|
<div id="app">
|
|
|
|
<div id="app">
|
|
|
|
<div class="content">
|
|
|
|
<div class="content">
|
|
|
|
<div class="messages">
|
|
|
|
<div class="messagesContainer">
|
|
|
|
<div class="spacer" style="height: 1rem;"></div>
|
|
|
|
<div id="messages" class="messages">
|
|
|
|
<message msg="Hey :D" />
|
|
|
|
<message msg="Hey :D" />
|
|
|
|
<message msg="Du bist blööööd xD" />
|
|
|
|
<message msg="Du bist blööööd xD" />
|
|
|
|
<messageReceive msg="Du auch" />
|
|
|
|
<messageReceive msg="Du auch" />
|
|
|
@ -24,10 +24,10 @@
|
|
|
|
<message msg="und Kuchen :P" />
|
|
|
|
<message msg="und Kuchen :P" />
|
|
|
|
<message msg="und Kuchen :P" />
|
|
|
|
<message msg="und Kuchen :P" />
|
|
|
|
<message msg="und Kuchen :P" />
|
|
|
|
<message msg="und Kuchen :P" />
|
|
|
|
<div class="spacer" style="height: 1rem;"></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<newMessage />
|
|
|
|
<newMessage />
|
|
|
|
<error msg="fehler!"/>
|
|
|
|
<error />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
@ -47,36 +47,6 @@ export default {
|
|
|
|
error
|
|
|
|
error
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const wsurl = 'ws://127.0.0.1:8090'
|
|
|
|
|
|
|
|
const socket = new WebSocket(wsurl)
|
|
|
|
|
|
|
|
function element(id){ return document.getElementById(id)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
socket.onopen = () => {
|
|
|
|
|
|
|
|
socket.send('new session')
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
socket.onerror = (error) => {
|
|
|
|
|
|
|
|
console.log(`WebSocket error: ${error}`)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
socket.onclose = () => show_error('session timed out (refresh)')
|
|
|
|
|
|
|
|
socket.onmessage = (e) => {
|
|
|
|
|
|
|
|
console.log(e.data)
|
|
|
|
|
|
|
|
let msg = e.data.split(";", 2)
|
|
|
|
|
|
|
|
if (msg[0] === 'error') show_error(msg[1])
|
|
|
|
|
|
|
|
else if (msg[0] === 'message');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function show_error(msg) {
|
|
|
|
|
|
|
|
let error_style = element('errorBox').style
|
|
|
|
|
|
|
|
element('errorMessage').innerText = msg
|
|
|
|
|
|
|
|
error_style.display = "block"
|
|
|
|
|
|
|
|
error_style.animation = "slide-from-left alternate 0.2s"
|
|
|
|
|
|
|
|
setTimeout(() => {error_style.animation = ""}, 200)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*function sendMessage(msg, user){
|
|
|
|
|
|
|
|
socket.send(`message;${user};${msg}`)
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
<style>
|
|
|
@ -102,15 +72,20 @@ body{
|
|
|
|
background-color: #313131;
|
|
|
|
background-color: #313131;
|
|
|
|
box-shadow: 3px 3px 10px #111;
|
|
|
|
box-shadow: 3px 3px 10px #111;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.messages{
|
|
|
|
.messagesContainer{
|
|
|
|
position: absolute;
|
|
|
|
position: absolute;
|
|
|
|
margin: 0;
|
|
|
|
margin: 0;
|
|
|
|
|
|
|
|
padding-bottom: 1rem;
|
|
|
|
left: 0;
|
|
|
|
left: 0;
|
|
|
|
top: 0;
|
|
|
|
top: 0;
|
|
|
|
height: calc(100% - 4rem);
|
|
|
|
height: calc(100% - 5rem);
|
|
|
|
width: 100%;
|
|
|
|
width: 100%;
|
|
|
|
overflow-y: auto;
|
|
|
|
overflow-y: auto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.messages{
|
|
|
|
|
|
|
|
margin-top: 1rem;
|
|
|
|
|
|
|
|
margin-bottom: 1rem;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@media (max-width: 55rem){
|
|
|
|
@media (max-width: 55rem){
|
|
|
|
.content{
|
|
|
|
.content{
|
|
|
|