Jake Probst
5 years ago
2 changed files with 28 additions and 16 deletions
@ -1,21 +1,26 @@ |
|||
use libpso::{PSOPacket, PacketParseError};
|
|||
use libpso::PacketParseError;
|
|||
use libpso::crypto::PSOCipher;
|
|||
|
|||
|
|||
pub enum OnConnect {
|
|||
Packet(Box<dyn PSOPacket>),
|
|||
pub enum OnConnect<S: SendServerPacket> {
|
|||
Packet(S),
|
|||
Cipher((Box<dyn PSOCipher>, Box<dyn PSOCipher>)),
|
|||
}
|
|||
|
|||
pub trait ServerPacket: Sized {
|
|||
pub trait RecvServerPacket: Sized {
|
|||
fn from_bytes(data: &Vec<u8>) -> Result<Self, PacketParseError>;
|
|||
}
|
|||
|
|||
pub trait SendServerPacket: Sized {
|
|||
fn as_bytes(&self) -> Vec<u8>;
|
|||
}
|
|||
|
|||
pub trait ServerState {
|
|||
type Packet: ServerPacket;
|
|||
type SendPacket: SendServerPacket;
|
|||
type RecvPacket: RecvServerPacket;
|
|||
type PacketError;
|
|||
|
|||
fn on_connect(&mut self) -> Vec<OnConnect>;
|
|||
fn handle(&mut self, pkt: &Self::Packet) -> Box<dyn Iterator<Item = Box<dyn PSOPacket>>>;
|
|||
fn on_connect(&mut self) -> Vec<OnConnect<Self::SendPacket>>;
|
|||
fn handle(&mut self, pkt: &Self::RecvPacket) -> Box<dyn Iterator<Item = Self::SendPacket>>;
|
|||
}
|
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue