1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Create RC database layer

This commit is contained in:
NGnius (Graham)
2025-05-07 20:23:22 -04:00
parent 69c6c54650
commit 77ddeb7891
55 changed files with 2689 additions and 395 deletions

View File

@@ -16,3 +16,4 @@ polariton.workspace = true
polariton_auth = { version = "*", path = "../polariton_auth" }
polariton_server.workspace = true
rc_core = { version = "*", path = "../rc_core" }
async-trait.workspace = true

View File

@@ -19,7 +19,7 @@ async fn main() -> std::io::Result<()> {
log::debug!("Got cli args {:?}", args);
let cubes = rc_core::persist::config::ConfigImpl::load(&args.assets).expect("Bad config data");
let users = std::sync::Arc::new(rc_core::persist::user::UserImpl::load(&args.data, &cubes).expect("Bad user data"));
let users = std::sync::Arc::new(rc_core::persist::user::UserImpl::load(&args.data, &cubes).await.expect("Bad user data"));
let server = std::sync::Arc::new(polariton_server::Server::new(operations::handler(), polariton_server::events::EventsHandler::new()));

View File

@@ -7,17 +7,18 @@ impl MoreLobbyAuth {
const AUTH_PAYLOAD_KEY: u8 = 245;
}
#[async_trait::async_trait]
impl <C: Send + 'static> Operation<C> for MoreLobbyAuth {
type User = crate::UserTy;
fn handle(&self, params: polariton::operation::ParameterTable<C>, user: &Self::User) -> polariton::operation::OperationResponse<C> {
async fn handle_async(&self, params: polariton::operation::ParameterTable<C>, user: &Self::User) -> polariton::operation::OperationResponse<C> {
let params_dict = params.to_dict();
if let Some(Typed::Str(auth_payload)) = params_dict.get(&Self::AUTH_PAYLOAD_KEY) {
if user.update_with_auth(&auth_payload.string) {
if user.update_with_auth(&auth_payload.string).await {
let mut resp_params = std::collections::HashMap::with_capacity(1);
resp_params.insert(Self::AUTH_PAYLOAD_KEY, polariton::operation::Typed::Byte(0));
return polariton::operation::OperationResponse {
code: 230,
code: Self::op_code(),
return_code: 0,
message: polariton::operation::Typed::Null,
params: resp_params.into(),
@@ -25,7 +26,7 @@ impl <C: Send + 'static> Operation<C> for MoreLobbyAuth {
}
}
polariton::operation::OperationResponse {
code: 230,
code: Self::op_code(),
return_code: 120,
message: polariton::operation::Typed::Null,
params: std::collections::HashMap::new().into(),