feat: stuff
This commit is contained in:
parent
6f02339464
commit
b8d2cd7b09
3 changed files with 308 additions and 13 deletions
|
|
@ -514,9 +514,9 @@ pub struct NewEncryptionPair<E: StreamCipher> {
|
|||
|
||||
pub struct CommonConnection {
|
||||
pub user_id: u32,
|
||||
session_id: u8,
|
||||
pub socket_addr: PRUDPSockAddr,
|
||||
pub server_port: VirtualPort
|
||||
pub server_port: VirtualPort,
|
||||
session_id: u8,
|
||||
}
|
||||
|
||||
struct InternalConnection<E: CryptoHandlerConnectionInstance> {
|
||||
|
|
@ -670,6 +670,8 @@ impl<T: CryptoHandler> InternalSocket<T> {
|
|||
.write_to(&mut vec)
|
||||
.expect("somehow failed to convert backet to bytes");
|
||||
|
||||
println!("{}", hex::encode(&vec));
|
||||
|
||||
self.socket
|
||||
.send_to(&vec, dest.regular_socket_addr)
|
||||
.await
|
||||
|
|
|
|||
|
|
@ -11,10 +11,11 @@ use tokio::sync::{Mutex, Notify};
|
|||
use tokio::time::{sleep_until, Instant};
|
||||
use crate::prudp::socket::{ExternalConnection, SendingConnection};
|
||||
use crate::rmc::structures::connection_data::ConnectionData;
|
||||
use crate::rmc::structures::matchmake::AutoMatchmakeParam;
|
||||
|
||||
struct RmcConnection(SendingConnection, RmcResponseReceiver);
|
||||
pub struct RmcConnection(pub SendingConnection, pub RmcResponseReceiver);
|
||||
|
||||
struct RmcResponseReceiver(Notify, Mutex<HashMap<(u16, u32), Vec<u8>>>);
|
||||
pub struct RmcResponseReceiver(Notify, Mutex<HashMap<(u16, u32), Vec<u8>>>);
|
||||
|
||||
impl RmcResponseReceiver{
|
||||
// returns none if timed out
|
||||
|
|
@ -48,17 +49,29 @@ impl RmcResponseReceiver{
|
|||
}
|
||||
}
|
||||
|
||||
pub trait RemoteObject{
|
||||
fn new(conn: RmcConnection) -> Self;
|
||||
}
|
||||
|
||||
impl RemoteObject for (){
|
||||
fn new(_: RmcConnection) -> Self {}
|
||||
}
|
||||
|
||||
pub trait RmcCallable{
|
||||
//type Remote: RemoteObject;
|
||||
//fn new_callable(remote: Self::Remote);
|
||||
async fn rmc_call(&self, protocol_id: u16, method_id: u32, rest: Vec<u8>);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
macro_rules! define_rmc_proto {
|
||||
(proto $name:ident{
|
||||
$($protocol:path),*
|
||||
}) => {
|
||||
paste!{
|
||||
trait [<Local $name>]: std::any::Any $( + [<Raw $protocol>])* {
|
||||
trait [<Local $name>]: std::any::Any $( + [<Raw $protocol>] + $protocol)* {
|
||||
async fn rmc_call(&self, protocol_id: u16, method_id: u32, rest: Vec<u8>){
|
||||
match protocol_id{
|
||||
$(
|
||||
|
|
@ -77,16 +90,21 @@ trait RawNotif{
|
|||
|
||||
}
|
||||
}
|
||||
trait Notif{
|
||||
|
||||
}
|
||||
|
||||
struct RawNotifInfo;
|
||||
impl RawNotifInfo{
|
||||
const PROTOCOL_ID: u16 = 10;
|
||||
}
|
||||
|
||||
#[rmc_proto(1)]
|
||||
pub trait ImplementRemoteCalls{}
|
||||
|
||||
#[rmc_proto(1, NoReturn)]
|
||||
pub trait Another{
|
||||
#[method_id(1)]
|
||||
async fn test();
|
||||
async fn test(&self, thing: AutoMatchmakeParam);
|
||||
}
|
||||
|
||||
define_rmc_proto!{
|
||||
|
|
@ -100,6 +118,12 @@ define_rmc_proto!{
|
|||
|
||||
#[rmc_struct(TestProto)]
|
||||
struct TestProtoImplementor{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
impl Notif for TestProtoImplementor{
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -107,3 +131,10 @@ impl RawNotif for TestProtoImplementor{
|
|||
|
||||
}
|
||||
|
||||
impl Another for TestProtoImplementor{
|
||||
async fn test(&self, thing: AutoMatchmakeParam) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
impl ImplementRemoteCalls for TestProtoImplementor{}
|
||||
Loading…
Add table
Add a link
Reference in a new issue