usimp websocket things

This commit is contained in:
2021-05-22 16:26:48 +02:00
parent 0e9caa496f
commit faa8c8e0a5
2 changed files with 44 additions and 13 deletions

View File

@ -1,5 +1,6 @@
mod handler;
use serde::{Deserialize, Serialize};
use crate::error::Error;
use crate::http;
pub use handler::*;
@ -45,6 +46,21 @@ pub struct TextMessage {
data: String,
}
#[derive(Serialize, Deserialize)]
pub struct RequestEnvelope {
endpoint: String,
request_nr: u64,
data: serde_json::Value,
}
#[derive(Serialize, Deserialize)]
pub struct ResponseEnvelope {
to_request_nr: u64,
status: String,
message: Option<String>,
data: serde_json::Value,
}
impl FrameHeader {
pub fn from(socket: &mut http::Stream) -> Result<Self, Error> {
let mut data = [0u8; 2];