mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Add support for matchmaker sending clients off to game server
This commit is contained in:
@@ -13,14 +13,16 @@ const EVENT_TO_JOIN_PARAM_KEY: u8 = 41; // str; in
|
||||
const ESTIMATED_QUEUE_TIME_PARAM_KEY: u8 = 13; // int (seconds); out
|
||||
const PERSONAL_RANKING_PARAM_KEY: u8 = 17; // double; out
|
||||
|
||||
pub(super) struct QueueJoinProvider;
|
||||
pub(super) struct QueueJoinProvider {
|
||||
queue_handler: std::sync::Arc<crate::QueueHandler>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl <C: Send + 'static> SimpleOperation<C> for QueueJoinProvider {
|
||||
type User = crate::UserTy;
|
||||
const CODE: u8 = CODE;
|
||||
|
||||
async fn handle(&self, params: ParameterTable<C>, _user: &Self::User) -> Result<ParameterTable<C>, SimpleOpError> {
|
||||
async fn handle(&self, params: ParameterTable<C>, user: &Self::User) -> Result<ParameterTable<C>, SimpleOpError> {
|
||||
let mut params = params.to_dict();
|
||||
if let Some(Typed::Str(group_id)) = params.remove(&GROUP_ID_PARAM_KEY) {
|
||||
if let Some(Typed::Int(slot_id)) = params.remove(&GARAGE_SLOT_PARAM_KEY) {
|
||||
@@ -32,6 +34,16 @@ impl <C: Send + 'static> SimpleOperation<C> for QueueJoinProvider {
|
||||
log::debug!("Got lobby join queue request of platoon {} ({} players, is_leader:{}) slot {} lobby {:?} event {}", group_id.string, group_size, is_leader, slot_id, lobby_ty, event_to_join.string);
|
||||
params.insert(ESTIMATED_QUEUE_TIME_PARAM_KEY, Typed::Int(42));
|
||||
params.insert(PERSONAL_RANKING_PARAM_KEY, Typed::Double(42.0));
|
||||
let events = user.event_sender();
|
||||
let user_info = user.user()?;
|
||||
self.queue_handler.join_queue(
|
||||
"FIXME_map".to_owned(),
|
||||
oj_rc_core::data::game_mode::GameMode::BattleArena, // FIXME
|
||||
oj_rc_core::data::game_mode::MapVisibility::Good, // FIXME
|
||||
true, // FIXME
|
||||
user_info.as_ref().as_ref(),
|
||||
events.to_owned(),
|
||||
).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,6 +54,8 @@ impl <C: Send + 'static> SimpleOperation<C> for QueueJoinProvider {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn join_queue_provider<C: Send + 'static>() -> SimpleOpImpl<C, crate::UserTy, QueueJoinProvider> {
|
||||
SimpleOpImpl::new(QueueJoinProvider)
|
||||
pub(super) fn join_queue_provider<C: Send + 'static>(queue_handler: &std::sync::Arc<crate::QueueHandler>) -> SimpleOpImpl<C, crate::UserTy, QueueJoinProvider> {
|
||||
SimpleOpImpl::new(QueueJoinProvider {
|
||||
queue_handler: queue_handler.to_owned(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -5,12 +5,12 @@ mod join_queue;
|
||||
|
||||
use polariton_server::operations::OperationsHandler;
|
||||
|
||||
pub fn handler(_init_ctx: &crate::InitConfig) -> OperationsHandler<crate::UserTy> {
|
||||
pub fn handler(init_ctx: &crate::InitConfig) -> OperationsHandler<crate::UserTy> {
|
||||
OperationsHandler::<crate::UserTy>::new()
|
||||
.modify(oj_rc_core::polariton::RcOpModifier)
|
||||
.add(more_auth::MoreLobbyAuth)
|
||||
//.add(eac::EacChallengeIgnorer)
|
||||
//.add(polariton_server::operations::Ack::<2, _>::default())
|
||||
.add(no_quit::quit_blocker_provider())
|
||||
.add(join_queue::join_queue_provider())
|
||||
.add(join_queue::join_queue_provider(&init_ctx.queue))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user