Browse Source

add client_id arg to on_connect

pbs
jake 5 years ago
parent
commit
929f0e7f85
  1. 2
      src/common/mainloop.rs
  2. 2
      src/common/serverstate.rs
  3. 2
      src/login/character.rs
  4. 2
      src/login/login.rs
  5. 2
      src/patch/main.rs

2
src/common/mainloop.rs

@ -23,7 +23,7 @@ fn recv_from_clientpool<STATE, S, R, E>(state: &mut STATE,
Ok(incoming) => { Ok(incoming) => {
match incoming { match incoming {
ClientPoolAction::NewClient(client_id) => { ClientPoolAction::NewClient(client_id) => {
for s in state.on_connect().into_iter() {
for s in state.on_connect(client_id).into_iter() {
match s { match s {
OnConnect::Cipher((in_cipher, out_cipher)) => { OnConnect::Cipher((in_cipher, out_cipher)) => {
pool_send.send(ClientAction::EncryptionKeys(client_id, in_cipher, out_cipher)).unwrap(); pool_send.send(ClientAction::EncryptionKeys(client_id, in_cipher, out_cipher)).unwrap();

2
src/common/serverstate.rs

@ -22,7 +22,7 @@ pub trait ServerState {
type RecvPacket: RecvServerPacket; type RecvPacket: RecvServerPacket;
type PacketError; type PacketError;
fn on_connect(&mut self) -> Vec<OnConnect<Self::SendPacket>>;
fn on_connect(&mut self, id: ClientId) -> Vec<OnConnect<Self::SendPacket>>;
fn handle(&mut self, id: ClientId, pkt: &Self::RecvPacket) -> Box<dyn Iterator<Item = (ClientId, Self::SendPacket)>>; fn handle(&mut self, id: ClientId, pkt: &Self::RecvPacket) -> Box<dyn Iterator<Item = (ClientId, Self::SendPacket)>>;
} }

2
src/login/character.rs

@ -246,7 +246,7 @@ impl<DA: DataAccess> ServerState for CharacterServerState<DA> {
type RecvPacket = RecvCharacterPacket; type RecvPacket = RecvCharacterPacket;
type PacketError = CharacterError; type PacketError = CharacterError;
fn on_connect(&mut self) -> Vec<OnConnect<Self::SendPacket>> {
fn on_connect(&mut self, id: ClientId) -> Vec<OnConnect<Self::SendPacket>> {
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();
let mut server_key = [0u8; 48]; let mut server_key = [0u8; 48];

2
src/login/login.rs

@ -119,7 +119,7 @@ impl<DA: DataAccess> ServerState for LoginServerState<DA> {
type RecvPacket = RecvLoginPacket; type RecvPacket = RecvLoginPacket;
type PacketError = LoginError; type PacketError = LoginError;
fn on_connect(&mut self) -> Vec<OnConnect<Self::SendPacket>> {
fn on_connect(&mut self, id: ClientId) -> Vec<OnConnect<Self::SendPacket>> {
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();
let mut server_key = [0u8; 48]; let mut server_key = [0u8; 48];

2
src/patch/main.rs

@ -170,7 +170,7 @@ impl ServerState for PatchServerState {
type RecvPacket = RecvPatchPacket; type RecvPacket = RecvPatchPacket;
type PacketError = PatchError; type PacketError = PatchError;
fn on_connect(&mut self) -> Vec<OnConnect<Self::SendPacket>> {
fn on_connect(&mut self, _id: ClientId) -> Vec<OnConnect<Self::SendPacket>> {
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();
let key_in: u32 = rng.gen(); let key_in: u32 = rng.gen();
let key_out: u32 = rng.gen(); let key_out: u32 = rng.gen();

Loading…
Cancel
Save