forked from spacebar/rust-nex
feat(matchmaking): method 15 - getdetailedparticipants
This commit is contained in:
parent
be7bc79762
commit
2a82146a45
2 changed files with 35 additions and 3 deletions
|
|
@ -150,6 +150,15 @@ pub struct MatchmakeBlockListParam {
|
|||
option_flag: u32,
|
||||
}
|
||||
|
||||
#[derive(RmcSerialize, Debug, Clone)]
|
||||
#[rmc_struct(0)]
|
||||
pub struct ParticipantDetails {
|
||||
pub participant: PID,
|
||||
pub name: String,
|
||||
pub message: String,
|
||||
pub participants: u16,
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "v3-10-22")] {
|
||||
#[derive(RmcSerialize, Debug, Clone)]
|
||||
|
|
@ -200,6 +209,8 @@ pub mod gathering_flags {
|
|||
pub trait Matchmake {
|
||||
#[method_id(2)]
|
||||
async fn unregister_gathering(&self, gid: u32) -> Result<bool, ErrorCode>;
|
||||
#[method_id(15)]
|
||||
async fn get_detailed_participants(&self, gid: u32) -> Result<Vec<ParticipantDetails>, ErrorCode>;
|
||||
#[method_id(21)]
|
||||
async fn find_by_single_id(&self, gid: u32) -> Result<(bool, Any<Gathering>), ErrorCode>;
|
||||
#[method_id(41)]
|
||||
|
|
|
|||
|
|
@ -6,12 +6,11 @@ use rnex_mm_protos::{
|
|||
LocalMatchMakingProtocol, RemoteMatchMakingClientProtocol,
|
||||
matchmake::{
|
||||
AutoMatchmakeParam, CreateMatchmakeSessionParam, Gathering, JoinMatchmakeSessionParam,
|
||||
Matchmake, MatchmakeSession, MatchmakeSessionSearchCriteria,
|
||||
Matchmake, MatchmakeSession, MatchmakeSessionSearchCriteria, ParticipantDetails,
|
||||
},
|
||||
matchmake_ext::MatchmakeExt,
|
||||
matchmake_extension::MatchmakeExtension,
|
||||
nat_traversal::NatTraversal,
|
||||
nat_traversal::RemoteNatTraversalConsole,
|
||||
nat_traversal::{NatTraversal, RemoteNatTraversalConsole},
|
||||
notifications::{
|
||||
NotificationEvent, RemoteNotification,
|
||||
notification_types::{END_GATHERING, REQUEST_JOIN_GATHERING},
|
||||
|
|
@ -633,6 +632,28 @@ impl Matchmake for MatchmakeUser {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn get_detailed_participants(&self, gid: u32) -> Result<Vec<ParticipantDetails>, ErrorCode> {
|
||||
let session = self.matchmake_manager.get_session(gid).await?;
|
||||
let session = session.lock().await;
|
||||
|
||||
let mut participant_details = Vec::with_capacity(session.connected_players.len());
|
||||
|
||||
for player_weak in &session.connected_players {
|
||||
let Some(player) = player_weak.upgrade() else {
|
||||
continue;
|
||||
};
|
||||
|
||||
participant_details.push(ParticipantDetails {
|
||||
participant: player.base.pid,
|
||||
name: "test".to_string(),
|
||||
message: String::new(),
|
||||
participants: 1,
|
||||
});
|
||||
}
|
||||
|
||||
Ok(participant_details)
|
||||
}
|
||||
}
|
||||
|
||||
impl MatchmakeExt for MatchmakeUser {
|
||||
|
|
|
|||
Loading…
Reference in a new issue