feat(secure): add get_playing_session and start working on auto_matchmake_with_param_postpone with RmcSerialize macro
This commit is contained in:
parent
d8c184171d
commit
d01acbb931
16 changed files with 338 additions and 23 deletions
4
src/protocols/matchmake_common/mod.rs
Normal file
4
src/protocols/matchmake_common/mod.rs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
pub struct MatchmakeData{
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
use std::sync::Arc;
|
||||
use tokio::sync::Mutex;
|
||||
use crate::protocols::matchmake_common::MatchmakeData;
|
||||
use crate::prudp::socket::ConnectionData;
|
||||
use crate::rmc::message::RMCMessage;
|
||||
|
||||
pub async fn auto_matchmake_with_param_postpone_raw_params(rmcmessage: &RMCMessage, _: &mut ConnectionData, data: Arc<Mutex<MatchmakeData>>){
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
use std::io::Cursor;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::Mutex;
|
||||
use crate::protocols::matchmake_common::MatchmakeData;
|
||||
use crate::prudp::socket::ConnectionData;
|
||||
use crate::rmc::message::RMCMessage;
|
||||
use crate::rmc::response::{ErrorCode, RMCResponseResult};
|
||||
use crate::rmc::structures::RmcSerialize;
|
||||
|
||||
type PIDList = Vec<u32>;
|
||||
|
||||
async fn get_playing_session(rmcmessage: &RMCMessage, data: Arc<Mutex<MatchmakeData>>) -> RMCResponseResult {
|
||||
//todo: propperly implement this
|
||||
|
||||
let cheeseburger = PIDList::new();
|
||||
|
||||
let mut vec = Vec::new();
|
||||
|
||||
cheeseburger.serialize(&mut vec).expect("somehow unable to write cheeseburger");
|
||||
|
||||
rmcmessage.success_with_data(vec)
|
||||
}
|
||||
|
||||
pub async fn get_playing_session_raw_params(rmcmessage: &RMCMessage, _: &mut ConnectionData, data: Arc<Mutex<MatchmakeData>>) -> RMCResponseResult{
|
||||
let mut reader = Cursor::new(&rmcmessage.rest_of_data);
|
||||
|
||||
let Ok(list) = PIDList::deserialize(&mut reader) else {
|
||||
return rmcmessage.error_result_with_code(ErrorCode::FPD_FriendNotExists);
|
||||
};
|
||||
|
||||
get_playing_session(rmcmessage, data).await
|
||||
}
|
||||
14
src/protocols/matchmake_extension/mod.rs
Normal file
14
src/protocols/matchmake_extension/mod.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
mod method_get_playing_session;
|
||||
mod method_auto_matchmake_with_param_postpone;
|
||||
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::Mutex;
|
||||
use crate::define_protocol;
|
||||
use crate::protocols::matchmake_common::MatchmakeData;
|
||||
use method_get_playing_session::get_playing_session_raw_params;
|
||||
|
||||
define_protocol!{
|
||||
109(matchmake_data: Arc<Mutex<MatchmakeData>>) => {
|
||||
16 => get_playing_session_raw_params
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,8 @@ use crate::prudp::socket::ConnectionData;
|
|||
pub mod auth;
|
||||
pub mod server;
|
||||
pub mod secure;
|
||||
pub mod matchmake_extension;
|
||||
pub mod matchmake_common;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! define_protocol {
|
||||
|
|
@ -40,11 +42,17 @@ macro_rules! define_protocol {
|
|||
-> ::std::pin::Pin<Box<dyn ::std::future::Future<Output = Option<crate::rmc::response::RMCResponse>> + Send + 'message_lifetime>> + Send + Sync>{
|
||||
Box::new(
|
||||
move |v, cd| {
|
||||
Box::pin(async move {
|
||||
Box::pin({
|
||||
$(
|
||||
let $varname = $varname.clone();
|
||||
)*
|
||||
protocol(v, cd, $($varname,)*).await
|
||||
|
||||
async move {
|
||||
$(
|
||||
let $varname = $varname.clone();
|
||||
)*
|
||||
protocol(v, cd, $($varname,)*).await
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue