add channel open support

This commit is contained in:
nora 2022-02-19 23:25:06 +01:00
parent dc8efd4e4e
commit 46cccab748
10 changed files with 1950 additions and 1462 deletions

View file

@ -55,6 +55,13 @@ struct Data {
struct Connection {
id: String,
peer_addr: String,
channels: Vec<Channel>,
}
#[derive(Serialize)]
struct Channel {
id: String,
number: u16,
}
async fn get_data(global_data: GlobalData) -> impl IntoResponse {
@ -68,6 +75,17 @@ async fn get_data(global_data: GlobalData) -> impl IntoResponse {
Connection {
id: conn.id.to_string(),
peer_addr: conn.peer_addr.to_string(),
channels: conn
.channels
.values()
.map(|chan| {
let chan = chan.lock();
Channel {
id: chan.id.to_string(),
number: chan.num,
}
})
.collect(),
}
})
.collect();