mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Implement minimal chat service, fix some implement bugs
This commit is contained in:
@@ -4,7 +4,7 @@ use clap::Parser;
|
||||
#[command(version, about, long_about = None)]
|
||||
pub struct CliArgs {
|
||||
/// TCP port on which to accept connections
|
||||
#[arg(short, long, default_value_t = 4535)]
|
||||
#[arg(short, long, default_value_t = 4537)]
|
||||
pub port: u16,
|
||||
|
||||
/// IP Address on which to accept connections
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
use polariton::operation::Typed;
|
||||
|
||||
pub struct ClanInviteInfo {
|
||||
pub username: String,
|
||||
pub display_name: String,
|
||||
pub clan_name: String,
|
||||
pub clan_size: i32,
|
||||
pub use_custom_avatar: bool,
|
||||
pub avatar_id: i32,
|
||||
}
|
||||
|
||||
impl ClanInviteInfo {
|
||||
pub fn as_transmissible(&self) -> Typed {
|
||||
Typed::HashMap(vec![
|
||||
(Typed::Str("userName".into()), Typed::Str(self.username.clone().into())),
|
||||
(Typed::Str("displayName".into()), Typed::Str(self.display_name.clone().into())),
|
||||
(Typed::Str("clanName".into()), Typed::Str(self.clan_name.clone().into())),
|
||||
(Typed::Str("clanSize".into()), Typed::Int(self.clan_size)),
|
||||
(Typed::Str("useCustomAvatar".into()), Typed::Bool(self.use_custom_avatar.into())),
|
||||
(Typed::Str("avatarId".into()), Typed::Int(self.avatar_id)),
|
||||
].into())
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
use polariton::operation::Typed;
|
||||
|
||||
pub struct AvatarInfo {
|
||||
pub name: String,
|
||||
pub use_custom_avatar: bool,
|
||||
pub avatar_id: i32,
|
||||
}
|
||||
|
||||
impl AvatarInfo {
|
||||
pub fn as_transmissible(&self) -> Typed {
|
||||
Typed::HashMap(vec![
|
||||
(Typed::Str("name".into()), Typed::Str(self.name.clone().into())),
|
||||
(Typed::Str("useCustomAvatar".into()), Typed::Bool(self.use_custom_avatar.into())),
|
||||
(Typed::Str("avatarId".into()), Typed::Int(self.avatar_id)),
|
||||
].into())
|
||||
}
|
||||
}
|
||||
|
||||
// TODO pub struct FriendInfo {}
|
||||
@@ -1,2 +0,0 @@
|
||||
pub mod friend;
|
||||
pub mod clan_invite;
|
||||
|
||||
@@ -191,7 +191,7 @@ async fn send_packet(packet: Packet, buf: &mut Vec<u8>, socket: &mut net::TcpStr
|
||||
Ok(())
|
||||
}
|
||||
|
||||
const APP_ID: &str = "SocialServer";
|
||||
const APP_ID: &str = "ChatServer";
|
||||
|
||||
struct AuthImpl;
|
||||
|
||||
|
||||
17
rc_chat_room/src/operations/chat_ignores.rs
Normal file
17
rc_chat_room/src/operations/chat_ignores.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Arr};
|
||||
|
||||
const PARAM_KEY: u8 = 15;
|
||||
|
||||
pub(super) fn ignores_provider() -> SimpleFunc<8, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Arr(Arr {
|
||||
ty: 115, // str
|
||||
items: vec![
|
||||
Typed::Str("Pluto".into()),
|
||||
],
|
||||
}));
|
||||
Ok(params.into())
|
||||
})
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Arr};
|
||||
|
||||
use crate::data::clan_invite::*;
|
||||
|
||||
const PARAM_KEY: u8 = 42;
|
||||
|
||||
pub(super) fn clan_invites_provider() -> SimpleFunc<39, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Arr(Arr {
|
||||
ty: 104, // hashmap
|
||||
items: vec![
|
||||
ClanInviteInfo {
|
||||
username: "RE_user1".to_owned(),
|
||||
display_name: "RE_user1".to_owned(),
|
||||
clan_name: "RE_clan1".to_owned(),
|
||||
clan_size: 42,
|
||||
use_custom_avatar: false,
|
||||
avatar_id: 0,
|
||||
}.as_transmissible()
|
||||
],
|
||||
}));
|
||||
Ok(params.into())
|
||||
})
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Arr};
|
||||
|
||||
use crate::data::friend::*;
|
||||
|
||||
const FRIENDS_PARAM_KEY: u8 = 5;
|
||||
const AVATAR_PARAM_KEY: u8 = 76;
|
||||
|
||||
pub(super) fn friends_provider() -> SimpleFunc<4, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(FRIENDS_PARAM_KEY, Typed::Arr(Arr {
|
||||
ty: 99, // custom
|
||||
items: vec![Typed::Custom(vec![ // FIXME don't manually serialize
|
||||
0u8, // byte custom type
|
||||
0u8, 5u8, // short custom object size
|
||||
3u8, 0u8, 0u8, 0u8, 0u8, // content
|
||||
].into())] }));
|
||||
params.insert(AVATAR_PARAM_KEY, Typed::Arr(Arr {
|
||||
ty: 104, // hashmap
|
||||
items: vec![AvatarInfo {
|
||||
name: "".to_string(),
|
||||
use_custom_avatar: false,
|
||||
avatar_id: 1,
|
||||
}.as_transmissible()],
|
||||
}));
|
||||
Ok(params.into())
|
||||
})
|
||||
}
|
||||
@@ -1,17 +1,13 @@
|
||||
mod more_auth;
|
||||
mod friend_list;
|
||||
mod settings;
|
||||
mod clan_invite;
|
||||
mod chat_ignores;
|
||||
mod pending_sanctions;
|
||||
|
||||
use polariton_server::operations::OperationsHandler;
|
||||
|
||||
pub fn handler() -> OperationsHandler<crate::UserTy> {
|
||||
OperationsHandler::new()
|
||||
.without_state(more_auth::MoreLobbyAuth)
|
||||
.without_state(polariton_server::operations::Ack::<33, _>::default()) // get user clan info (this is equivalent to not being in a clan)
|
||||
.without_state(friend_list::friends_provider()) // TODO friend object parsing Token: 0x0200169C RID: 5788
|
||||
.without_state(settings::settings_provider()) // TODO save settings persistently
|
||||
.without_state(polariton_server::operations::Ack::<43, _>::default()) // get my clan info (this is equivalent to not being in a clan)
|
||||
.without_state(clan_invite::clan_invites_provider())
|
||||
.without_state(polariton_server::operations::Ack::<19, _>::default()) // get pending platoon invite (this is equivalent to having no pending invite)
|
||||
.without_state(chat_ignores::ignores_provider())
|
||||
.without_state(pending_sanctions::pending_sanctions_checker())
|
||||
//.without_state(polariton_server::operations::Ack::<00000, _>::default())
|
||||
}
|
||||
|
||||
12
rc_chat_room/src/operations/pending_sanctions.rs
Normal file
12
rc_chat_room/src/operations/pending_sanctions.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed};
|
||||
|
||||
const PARAM_KEY: u8 = 28;
|
||||
|
||||
pub(super) fn pending_sanctions_checker() -> SimpleFunc<15, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Bool(false.into()));
|
||||
Ok(params.into())
|
||||
})
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Arr};
|
||||
|
||||
use crate::data::friend::*;
|
||||
|
||||
const INVITER_NAME_PARAM_KEY: u8 = 19;
|
||||
const INVITER_DISPLAY_NAME_PARAM_KEY: u8 = 75;
|
||||
const INVITER_CUSTOM_AVATAR_NAME_PARAM_KEY: u8 = 13;
|
||||
const INVITER_AVATAR_ID_NAME_PARAM_KEY: u8 = 14;
|
||||
|
||||
pub(super) fn platoon_pending_provider() -> SimpleFunc<19, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(INVITER_NAME_PARAM_KEY, Typed::Str("RE_platoon_inviter".into())));
|
||||
params.insert(INVITER_DISPLAY_NAME_PARAM_KEY, Typed::Str("RE_platoon_inviter_display".into())));
|
||||
params.insert(INVITER_CUSTOM_AVATAR_NAME_PARAM_KEY, Typed::Bool(false.into())));
|
||||
params.insert(INVITER_AVATAR_ID_NAME_PARAM_KEY, Typed::Int(1)));
|
||||
Ok(params.into())
|
||||
})
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed, Dict};
|
||||
|
||||
const PARAM_KEY: u8 = 30;
|
||||
|
||||
pub(super) fn settings_provider() -> SimpleFunc<24, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||
SimpleFunc::new(|params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(PARAM_KEY, Typed::Dict(Dict {
|
||||
key_ty: 115,
|
||||
val_ty: 42,
|
||||
items: Vec::default(),
|
||||
}));
|
||||
Ok(params.into())
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user