parent
4c1aff8142
commit
f31fb3bcdc
|
@ -11,7 +11,7 @@ type AppState = Arc<Mutex<State>>;
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct State {
|
pub struct State {
|
||||||
uid: IdCounter,
|
uid: IdCounter,
|
||||||
message: String,
|
message: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
|
|
|
@ -42,7 +42,7 @@ pub enum MessageBody {
|
||||||
ReadOk {
|
ReadOk {
|
||||||
msg_id: u64,
|
msg_id: u64,
|
||||||
in_reply_to: u64,
|
in_reply_to: u64,
|
||||||
message: String,
|
message: Vec<String>,
|
||||||
},
|
},
|
||||||
Default,
|
Default,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use axum::{extract::State, http::StatusCode, Json};
|
use axum::{extract::State, http::StatusCode, Json};
|
||||||
use tracing::{info};
|
use tracing::info;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
messages::{Message, MessageBody},
|
messages::{Message, MessageBody},
|
||||||
|
@ -51,7 +51,7 @@ pub async fn challenge(
|
||||||
let in_reply_to = msg_id;
|
let in_reply_to = msg_id;
|
||||||
{
|
{
|
||||||
let mut local_state = state.lock().unwrap();
|
let mut local_state = state.lock().unwrap();
|
||||||
local_state.message = message;
|
local_state.message.push(message);
|
||||||
}
|
}
|
||||||
MessageBody::BroadcastOk {
|
MessageBody::BroadcastOk {
|
||||||
msg_id,
|
msg_id,
|
||||||
|
|
|
@ -85,7 +85,7 @@ async fn test_rw() {
|
||||||
"type": "read_ok",
|
"type": "read_ok",
|
||||||
"msg_id": 2,
|
"msg_id": 2,
|
||||||
"in_reply_to": 2,
|
"in_reply_to": 2,
|
||||||
"message": message
|
"message": vec![message]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue