Compare commits
No commits in common. "c66d68572dc963fb98cc133bbea2759f70fdbb35" and "eb9cbd9f665577725b17e24f6db01ffb73267ae7" have entirely different histories.
c66d68572d
...
eb9cbd9f66
@ -11,6 +11,9 @@ async function sendMsg(ev) {
|
|||||||
let msg = input.value
|
let msg = input.value
|
||||||
input.value = ''
|
input.value = ''
|
||||||
|
|
||||||
|
console.log(ws)
|
||||||
|
console.log(msg)
|
||||||
|
|
||||||
ws.send(msg)
|
ws.send(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,7 +29,6 @@ onMounted(async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ws.onmessage = function (event) {
|
ws.onmessage = function (event) {
|
||||||
console.log(event)
|
|
||||||
msgs.value.push(event.data)
|
msgs.value.push(event.data)
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -36,24 +38,33 @@ onMounted(async () => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<main>
|
<main>
|
||||||
<div class="overflow-auto position-relative pb-5">
|
<div class="container d-flex flex-column">
|
||||||
<div v-for="msg in msgs" class="card m-3 text-bg-secondary">
|
<div class="overflow-auto flex-1">
|
||||||
<div class="card-body">{{ msg }}</div>
|
<div v-for="msg in msgs" class="card m-3 text-bg-primary">
|
||||||
</div>
|
<div class="card-body">{{ msg }}</div>
|
||||||
<!--
|
|
||||||
<div v-for="msg in msgs" class="input-group">
|
|
||||||
<div class="alert alert-primary">User</div>
|
|
||||||
<div class="alert alert-secondary">{{ msg }}</div>
|
|
||||||
</div>
|
|
||||||
-->
|
|
||||||
<form onsubmit="event.preventDefault();" class="container-fluid fixed-bottom mb-3">
|
|
||||||
<div class="input-group">
|
|
||||||
<input v-model="input" type="text" class="form-control text-bg-secondary" placeholder="Type message here"
|
|
||||||
aria-label="Chat message" aria-describedby="button-submit">
|
|
||||||
<button @click="sendMsg" class="btn btn-primary" id="button-submit">Send</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<form onsubmit="event.preventDefault();" class="input-group m-3">
|
||||||
|
<input v-model="input" type="text" class="form-control" placeholder="Type message here" aria-label="Chat message"
|
||||||
|
aria-describedby="button-submit">
|
||||||
|
<button @click="sendMsg" class="btn btn-outline-secondary" id="button-submit">Send</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.container {
|
||||||
|
position: fixed;
|
||||||
|
height: 100vh;
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.overflow-auto {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|||||||
@ -2,10 +2,14 @@ use futures_util::{SinkExt, StreamExt};
|
|||||||
use poem::{
|
use poem::{
|
||||||
endpoint::StaticFilesEndpoint,
|
endpoint::StaticFilesEndpoint,
|
||||||
error::ResponseError,
|
error::ResponseError,
|
||||||
|
get, handler,
|
||||||
http::StatusCode,
|
http::StatusCode,
|
||||||
listener::TcpListener,
|
listener::TcpListener,
|
||||||
session::{CookieConfig, MemoryStorage, ServerSession, Session},
|
session::{CookieConfig, MemoryStorage, ServerSession, Session},
|
||||||
web::websocket::{BoxWebSocketUpgraded, Message, WebSocket},
|
web::{
|
||||||
|
websocket::{BoxWebSocketUpgraded, Message, WebSocket},
|
||||||
|
Html,
|
||||||
|
},
|
||||||
EndpointExt, Result, Route, Server,
|
EndpointExt, Result, Route, Server,
|
||||||
};
|
};
|
||||||
use poem_openapi::{
|
use poem_openapi::{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user