feat: private battles
This commit is contained in:
parent
33b0391ef3
commit
384f5abca5
21 changed files with 831 additions and 96 deletions
11
src/rmc/protocols/matchmake.rs
Normal file
11
src/rmc/protocols/matchmake.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
use macros::{method_id, rmc_proto};
|
||||
use crate::prudp::station_url::StationUrl;
|
||||
use crate::rmc::response::ErrorCode;
|
||||
|
||||
#[rmc_proto(21)]
|
||||
pub trait Matchmake{
|
||||
#[method_id(2)]
|
||||
async fn unregister_gathering(&self, gid: u32) -> Result<bool, ErrorCode>;
|
||||
#[method_id(41)]
|
||||
async fn get_session_urls(&self, gid: u32) -> Result<Vec<StationUrl>, ErrorCode>;
|
||||
}
|
||||
20
src/rmc/protocols/matchmake_extension.rs
Normal file
20
src/rmc/protocols/matchmake_extension.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
use macros::{method_id, rmc_proto};
|
||||
use crate::rmc::response::ErrorCode;
|
||||
use crate::rmc::structures::matchmake::{AutoMatchmakeParam, CreateMatchmakeSessionParam, JoinMatchmakeSessionParam, MatchmakeSession};
|
||||
|
||||
#[rmc_proto(109)]
|
||||
pub trait MatchmakeExtension{
|
||||
#[method_id(16)]
|
||||
async fn get_playing_session(&self, pids: Vec<u32>) -> Result<Vec<()>, ErrorCode>;
|
||||
|
||||
#[method_id(34)]
|
||||
async fn update_progress_score(&self, gid: u32, progress: u8) -> Result<(), ErrorCode>;
|
||||
#[method_id(38)]
|
||||
async fn create_matchmake_session_with_param(&self, session: CreateMatchmakeSessionParam) -> Result<MatchmakeSession, ErrorCode>;
|
||||
|
||||
#[method_id(39)]
|
||||
async fn join_matchmake_session_with_param(&self, session: JoinMatchmakeSessionParam) -> Result<MatchmakeSession, ErrorCode>;
|
||||
|
||||
#[method_id(40)]
|
||||
async fn auto_matchmake_with_param_postpone(&self, session: AutoMatchmakeParam) -> Result<MatchmakeSession, ErrorCode>;
|
||||
}
|
||||
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
pub mod auth;
|
||||
pub mod secure;
|
||||
pub mod notifications;
|
||||
pub mod matchmake;
|
||||
pub mod matchmake_extension;
|
||||
pub mod nat_traversal;
|
||||
|
||||
use crate::prudp::socket::{ExternalConnection, SendingConnection};
|
||||
use crate::rmc::message::RMCMessage;
|
||||
|
|
@ -261,7 +265,7 @@ async fn handle_incoming<T: RmcCallable + Send + Sync + 'static>(
|
|||
rest_of_data
|
||||
} = message;
|
||||
|
||||
info!("got rmc request, handeling it now...");
|
||||
info!("RMC REQUEST: Proto: {}; Method: {};", protocol_id, method_id);
|
||||
|
||||
remote.rmc_call(&sending_conn, protocol_id, method_id, call_id, rest_of_data).await;
|
||||
|
||||
|
|
@ -272,7 +276,7 @@ async fn handle_incoming<T: RmcCallable + Send + Sync + 'static>(
|
|||
|
||||
pub fn new_rmc_gateway_connection<T: RmcCallable + Sync + Send + 'static,F>(conn: ExternalConnection, create_internal: F) -> Arc<T>
|
||||
where
|
||||
F: FnOnce(RmcConnection) -> T,
|
||||
F: FnOnce(RmcConnection) -> Arc<T>,
|
||||
{
|
||||
let notify = Arc::new(Notify::new());
|
||||
let incoming: Arc<Mutex<HashMap<u32, RMCResponse>>> = Default::default();
|
||||
|
|
@ -285,8 +289,6 @@ where
|
|||
|
||||
let exposed_object = (create_internal)(rmc_conn);
|
||||
|
||||
let exposed_object = Arc::new(exposed_object);
|
||||
|
||||
{
|
||||
let exposed_object = exposed_object.clone();
|
||||
tokio::spawn(async move {
|
||||
|
|
|
|||
15
src/rmc/protocols/nat_traversal.rs
Normal file
15
src/rmc/protocols/nat_traversal.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
use macros::{method_id, rmc_proto};
|
||||
use crate::rmc::response::ErrorCode;
|
||||
use crate::rmc::structures::matchmake::{CreateMatchmakeSessionParam, MatchmakeSession};
|
||||
|
||||
#[rmc_proto(3)]
|
||||
pub trait NatTraversal{
|
||||
#[method_id(2)]
|
||||
async fn request_probe_initiation(&self, station_to_probe: String) -> Result<(),ErrorCode>;
|
||||
|
||||
#[method_id(3)]
|
||||
async fn request_probe_initialization_ext(&self, target_list: Vec<String>, station_to_probe: String) -> Result<(),ErrorCode>;
|
||||
|
||||
#[method_id(5)]
|
||||
async fn report_nat_properties(&self, nat_mapping: u32, nat_filtering: u32, rtt: u32) -> Result<(),ErrorCode>;
|
||||
}
|
||||
21
src/rmc/protocols/notifications.rs
Normal file
21
src/rmc/protocols/notifications.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
use macros::{method_id, rmc_proto, rmc_struct, RmcSerialize};
|
||||
use crate::rmc::response::ErrorCode;
|
||||
use crate::rmc::structures::qresult::QResult;
|
||||
|
||||
#[derive(RmcSerialize, Debug)]
|
||||
#[rmc_struct(0)]
|
||||
pub struct NotificationEvent{
|
||||
pub pid_source: u32,
|
||||
pub notif_type: u32,
|
||||
pub param_1: u32,
|
||||
pub param_2: u32,
|
||||
pub str_param: String,
|
||||
pub param_3: u32,
|
||||
}
|
||||
|
||||
#[rmc_proto(14, NoReturn)]
|
||||
pub trait Notification {
|
||||
#[method_id(1)]
|
||||
async fn process_notification_event(&self, event: NotificationEvent);
|
||||
}
|
||||
|
||||
|
|
@ -6,7 +6,9 @@ use crate::rmc::structures::connection_data::ConnectionData;
|
|||
use crate::rmc::structures::qresult::QResult;
|
||||
|
||||
#[rmc_proto(11)]
|
||||
pub trait Auth {
|
||||
pub trait Secure {
|
||||
#[method_id(1)]
|
||||
async fn register(&self, station_urls: Vec<String>) -> Result<(QResult, u32, String), ErrorCode>;
|
||||
async fn register(&self, station_urls: Vec<StationUrl>) -> Result<(QResult, u32, StationUrl), ErrorCode>;
|
||||
#[method_id(7)]
|
||||
async fn replace_url(&self, target: StationUrl, dest: StationUrl) -> Result<(), ErrorCode>;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue