mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Add social server and implement all op codes up until chat room connection blocks further requests
This commit is contained in:
1 parent
d8885d811f
commit
2907376722
76 files changed
+3052
-7
No files matched your search
@@ -0,0 +1,43 @@
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
pub struct State {
|
||||
pub crypto: Box<Arc<dyn polariton::packet::Cryptographer>>,
|
||||
}
|
||||
|
||||
impl State {
|
||||
pub fn new(c: Box<Arc<dyn polariton::packet::Cryptographer>>) -> Self {
|
||||
Self {
|
||||
crypto: c,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn binrw_args(&self) -> polariton::packet::WriteArgs {
|
||||
Some(self.crypto.clone())
|
||||
}
|
||||
|
||||
pub fn user(&self) -> crate::UserTy {
|
||||
RwLock::new(UserState::default())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
pub struct UserState {
|
||||
pub uuid: String,
|
||||
pub token: String,
|
||||
pub refresh_token: String,
|
||||
}
|
||||
|
||||
impl UserState {
|
||||
pub fn update_with_auth(&mut self, auth_str: &str) -> bool {
|
||||
let splits: Vec<&str> = auth_str.split(';').collect();
|
||||
if splits.len() != 3 {
|
||||
log::warn!("Invalid auth payload: {}", auth_str);
|
||||
false
|
||||
} else {
|
||||
self.uuid = splits[0].to_owned();
|
||||
self.token = splits[1].to_owned();
|
||||
self.refresh_token = splits[2].to_owned();
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user