fix: unhardcode matchmake session fields and fix other stuff
This commit is contained in:
parent
7703aafe3c
commit
b8cc89a6d9
6 changed files with 72 additions and 65 deletions
|
|
@ -97,7 +97,7 @@ impl Auth for AuthHandler {
|
|||
source_login_data.0,
|
||||
ticket.into(),
|
||||
connection_data,
|
||||
format!("{}; Rust NEX Version {} by DJMrTV", self.build_name, env!("CARGO_PKG_VERSION")),
|
||||
self.build_name.to_string() //format!("{}; Rust NEX Version {} by DJMrTV", self.build_name, env!("CARGO_PKG_VERSION")),
|
||||
))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -88,13 +88,13 @@ impl ExtendedMatchmakeSession{
|
|||
|
||||
let mm_session = MatchmakeSession{
|
||||
gathering: Gathering{
|
||||
self_gid: 1,
|
||||
self_gid: gid,
|
||||
owner_pid: host.pid,
|
||||
host_pid: host.pid,
|
||||
..session.gathering.clone()
|
||||
},
|
||||
datetime: KerberosDateTime::now(),
|
||||
session_key: vec![16, 118, 112, 238, 158, 122, 106, 219, 196, 238, 34, 21, 228, 127, 137, 75, 198, 215, 192, 113, 84, 157, 53, 144, 210, 99, 233, 179, 232, 113, 203, 64],//(0..32).map(|_| random()).collect(),
|
||||
session_key: (0..32).map(|_| random()).collect(),
|
||||
matchmake_param: MatchmakeParam{
|
||||
params: vec![
|
||||
("@SR".to_owned(), Variant::Bool(true)),
|
||||
|
|
@ -124,7 +124,7 @@ impl ExtendedMatchmakeSession{
|
|||
}
|
||||
self.session.participation_count = self.connected_players.len() as u32;
|
||||
|
||||
for other_connection in &self.connected_players[1..]{
|
||||
for other_connection in &conns[1..]{
|
||||
let Some(other_conn) = other_connection.upgrade() else {
|
||||
continue;
|
||||
};
|
||||
|
|
@ -146,7 +146,9 @@ impl ExtendedMatchmakeSession{
|
|||
}).await;
|
||||
}
|
||||
|
||||
for other_connection in &self.connected_players{
|
||||
let list_of_connected_pids: Vec<_> = self.connected_players.iter().filter_map(|p| p.upgrade()).map(|p| p.pid).collect();
|
||||
|
||||
for other_connection in conns{
|
||||
let Some(other_conn) = other_connection.upgrade() else {
|
||||
continue;
|
||||
};
|
||||
|
|
@ -158,24 +160,27 @@ impl ExtendedMatchmakeSession{
|
|||
continue;
|
||||
}*/
|
||||
|
||||
for pid in &list_of_connected_pids {
|
||||
other_conn.remote.process_notification_event(NotificationEvent {
|
||||
pid_source: initiating_pid,
|
||||
notif_type: 3001,
|
||||
param_1: self.session.gathering.self_gid,
|
||||
param_2: other_pid,
|
||||
param_2: *pid,
|
||||
str_param: join_msg.clone(),
|
||||
param_3: self.connected_players.len() as _
|
||||
}).await;
|
||||
}
|
||||
}
|
||||
|
||||
for old_conns in &old_particip{
|
||||
let Some(old_conns) = old_conns.upgrade() else {
|
||||
continue;
|
||||
};
|
||||
|
||||
|
||||
let older_pid = old_conns.pid;
|
||||
|
||||
|
||||
|
||||
initiating_user.remote.process_notification_event(NotificationEvent{
|
||||
pid_source: initiating_pid,
|
||||
notif_type: 3001,
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
use macros::rmc_struct;
|
||||
use crate::rmc::protocols::notifications::{Notification, NotificationEvent, RawNotification, RawNotificationInfo, RemoteNotification};
|
||||
use crate::rmc::protocols::nat_traversal::{NatTraversal, RemoteNatTraversal, RawNatTraversalInfo, RawNatTraversal};
|
||||
use crate::rmc::protocols::nat_traversal::{NatTraversalConsole, RemoteNatTraversalConsole, RawNatTraversalConsoleInfo, RawNatTraversalConsole};
|
||||
use crate::define_rmc_proto;
|
||||
use crate::nex::user::RemoteUserProtocol;
|
||||
|
||||
define_rmc_proto!(
|
||||
proto Console{
|
||||
Notification,
|
||||
NatTraversal
|
||||
NatTraversalConsole
|
||||
}
|
||||
);
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -15,9 +15,7 @@ use crate::rmc::protocols::matchmake::{
|
|||
use crate::rmc::protocols::matchmake_extension::{
|
||||
MatchmakeExtension, RawMatchmakeExtension, RawMatchmakeExtensionInfo, RemoteMatchmakeExtension,
|
||||
};
|
||||
use crate::rmc::protocols::nat_traversal::{
|
||||
NatTraversal, RawNatTraversal, RawNatTraversalInfo, RemoteNatTraversal,
|
||||
};
|
||||
use crate::rmc::protocols::nat_traversal::{NatTraversal, RawNatTraversal, RawNatTraversalInfo, RemoteNatTraversal, RemoteNatTraversalConsole};
|
||||
use crate::rmc::protocols::secure::{RawSecure, RawSecureInfo, RemoteSecure, Secure};
|
||||
use crate::rmc::protocols::matchmake_ext::{MatchmakeExt, RawMatchmakeExt, RawMatchmakeExtInfo, RemoteMatchmakeExt};
|
||||
use crate::rmc::response::ErrorCode;
|
||||
|
|
@ -230,12 +228,16 @@ impl MatchmakeExtension for User {
|
|||
|
||||
let users = self.matchmake_manager.users.read().await;
|
||||
|
||||
for pid in create_session_param.additional_participants{
|
||||
if let Some(user) = users.get(&pid){
|
||||
joining_players.push(user.clone());
|
||||
if let Ok(old_gathering) = self.matchmake_manager.get_session(create_session_param.gid_for_participation_check).await {
|
||||
let old_gathering = old_gathering.lock().await;
|
||||
|
||||
let players = old_gathering.connected_players.iter().filter_map(|v| v.upgrade()).filter(|u| create_session_param.additional_participants.iter().any(|p| *p == u.pid));
|
||||
for player in players {
|
||||
joining_players.push(Arc::downgrade(&player));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
drop(users);
|
||||
|
||||
new_session.session.participation_count = create_session_param.participation_count as u32;
|
||||
|
|
@ -266,9 +268,12 @@ impl MatchmakeExtension for User {
|
|||
|
||||
let users = self.matchmake_manager.users.read().await;
|
||||
|
||||
for pid in join_session_param.additional_participants{
|
||||
if let Some(user) = users.get(&pid){
|
||||
joining_players.push(user.clone());
|
||||
if let Ok(old_gathering) = self.matchmake_manager.get_session(join_session_param.gid_for_participation_check).await {
|
||||
let old_gathering = old_gathering.lock().await;
|
||||
|
||||
let players = old_gathering.connected_players.iter().filter_map(|v| v.upgrade()).filter(|u| join_session_param.additional_participants.iter().any(|p| *p == u.pid));
|
||||
for player in players {
|
||||
joining_players.push(Arc::downgrade(&player));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -290,9 +295,12 @@ impl MatchmakeExtension for User {
|
|||
|
||||
let users = self.matchmake_manager.users.read().await;
|
||||
|
||||
for pid in ¶m.additional_participants{
|
||||
if let Some(user) = users.get(pid){
|
||||
joining_players.push(user.clone());
|
||||
if let Ok(old_gathering) = self.matchmake_manager.get_session(param.gid_for_participation_check).await {
|
||||
let old_gathering = old_gathering.lock().await;
|
||||
|
||||
let players = old_gathering.connected_players.iter().filter_map(|v| v.upgrade()).filter(|u| param.additional_participants.iter().any(|p| *p == u.pid));
|
||||
for player in players {
|
||||
joining_players.push(Arc::downgrade(&player));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -321,8 +329,6 @@ impl MatchmakeExtension for User {
|
|||
|
||||
return Ok(session.session.clone());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
drop(sessions);
|
||||
|
|
@ -344,7 +350,7 @@ impl MatchmakeExtension for User {
|
|||
gid_for_participation_check,
|
||||
create_matchmake_session_option: 0,
|
||||
matchmake_session,
|
||||
additional_participants
|
||||
additional_participants,
|
||||
}).await
|
||||
}
|
||||
|
||||
|
|
@ -396,7 +402,7 @@ impl Matchmake for User {
|
|||
};
|
||||
|
||||
player.remote.process_notification_event(NotificationEvent {
|
||||
notif_type: 3008,
|
||||
notif_type: 110000,
|
||||
pid_source: self.pid,
|
||||
param_1: gid,
|
||||
param_2: self.pid,
|
||||
|
|
@ -447,7 +453,6 @@ impl NatTraversal for User {
|
|||
nat_filtering: u32,
|
||||
_rtt: u32,
|
||||
) -> Result<(), ErrorCode> {
|
||||
|
||||
let mut urls = self.station_url.write().await;
|
||||
|
||||
for station_url in urls.iter_mut() {
|
||||
|
|
@ -494,9 +499,7 @@ impl NatTraversal for User {
|
|||
continue;
|
||||
};
|
||||
|
||||
if let Err(e) = user.remote.request_probe_initiation(station_to_probe.clone()).await{
|
||||
error!("error whilest probing");
|
||||
}
|
||||
user.remote.request_probe_initiation(station_to_probe.clone()).await;
|
||||
}
|
||||
|
||||
info!("finished probing");
|
||||
|
|
|
|||
|
|
@ -709,7 +709,6 @@ impl ExternalConnection{
|
|||
|
||||
impl SendingConnection{
|
||||
pub async fn send(&self, data: Vec<u8>) -> Option<()> {
|
||||
println!("{}", hex::encode(&data));
|
||||
let internal = self.inernal.upgrade()?;
|
||||
|
||||
let mut internal = internal.lock().await;
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ pub trait NatTraversal{
|
|||
#[method_id(5)]
|
||||
async fn report_nat_properties(&self, nat_mapping: u32, nat_filtering: u32, rtt: u32) -> Result<(),ErrorCode>;
|
||||
}
|
||||
/*
|
||||
|
||||
#[rmc_proto(3, NoReturn)]
|
||||
pub trait NatTraversalConsole{
|
||||
#[method_id(2)]
|
||||
async fn request_probe_initiation(&self, station_to_probe: String) -> Result<(),ErrorCode>;
|
||||
}*/
|
||||
async fn request_probe_initiation(&self, station_to_probe: String);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue