mirror of https://github.com/CympleTech/ESSE.git
6 changed files with 82 additions and 14 deletions
@ -0,0 +1,47 @@ |
|||||||
|
use tdn::types::{ |
||||||
|
group::GroupId, |
||||||
|
message::{RecvType, SendType}, |
||||||
|
primitive::{new_io_error, HandleResult, Result}, |
||||||
|
}; |
||||||
|
|
||||||
|
use group_chat_types::{Event, GroupConnect, GroupEvent, GroupInfo, GroupResult, GroupType}; |
||||||
|
|
||||||
|
pub(crate) fn handle(mgid: GroupId, msg: RecvType) -> Result<HandleResult> { |
||||||
|
let mut results = HandleResult::new(); |
||||||
|
|
||||||
|
match msg { |
||||||
|
RecvType::Connect(addr, data) => { |
||||||
|
// None.
|
||||||
|
} |
||||||
|
RecvType::Leave(addr) => { |
||||||
|
//
|
||||||
|
} |
||||||
|
RecvType::Result(addr, is_ok, data) => { |
||||||
|
let res: GroupResult = postcard::from_bytes(&data) |
||||||
|
.map_err(|_e| new_io_error("Deseralize result failure"))?; |
||||||
|
match res { |
||||||
|
GroupResult::Check(is_ok, supported) => { |
||||||
|
println!("check: {}, supported: {:?}", is_ok, supported); |
||||||
|
} |
||||||
|
_ => { |
||||||
|
//
|
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
RecvType::ResultConnect(addr, data) => { |
||||||
|
let _res: GroupResult = postcard::from_bytes(&data) |
||||||
|
.map_err(|_e| new_io_error("Deseralize result failure"))?; |
||||||
|
} |
||||||
|
RecvType::Event(addr, bytes) => { |
||||||
|
//
|
||||||
|
} |
||||||
|
RecvType::Stream(_uid, _stream, _bytes) => { |
||||||
|
// TODO stream
|
||||||
|
} |
||||||
|
RecvType::Delivery(t, tid, is_ok) => { |
||||||
|
//
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
Ok(results) |
||||||
|
} |
@ -1,4 +1,16 @@ |
|||||||
mod models; |
mod models; |
||||||
|
|
||||||
|
pub use group_chat_types::GROUP_CHAT_ID as GROUP_ID; |
||||||
|
use tdn::types::{group::GroupId, message::SendType, primitive::HandleResult}; |
||||||
|
|
||||||
|
/// Group chat server to ESSE.
|
||||||
|
#[inline] |
||||||
|
pub(super) fn add_layer(results: &mut HandleResult, gid: GroupId, msg: SendType) { |
||||||
|
results.layers.push((gid, GROUP_ID, msg)); |
||||||
|
} |
||||||
|
|
||||||
pub(crate) mod rpc; |
pub(crate) mod rpc; |
||||||
pub(crate) use rpc::new_rpc_handler; |
pub(crate) use rpc::new_rpc_handler; |
||||||
|
|
||||||
|
mod layer; |
||||||
|
pub(crate) use layer::handle as layer_handle; |
||||||
|
Loading…
Reference in new issue