|
@ -456,7 +456,7 @@ impl<EG: EntityGateway> ServerState for ShipServerState<EG> { |
|
|
type RecvPacket = RecvShipPacket;
|
|
|
type RecvPacket = RecvShipPacket;
|
|
|
type PacketError = ShipError;
|
|
|
type PacketError = ShipError;
|
|
|
|
|
|
|
|
|
async fn on_connect(&mut self, _id: ClientId) -> Vec<OnConnect<Self::SendPacket>> {
|
|
|
|
|
|
|
|
|
async fn on_connect(&mut self, _id: ClientId) -> Result<Vec<OnConnect<Self::SendPacket>>, ShipError> {
|
|
|
let mut rng = rand::thread_rng();
|
|
|
let mut rng = rand::thread_rng();
|
|
|
|
|
|
|
|
|
let mut server_key = [0u8; 48];
|
|
|
let mut server_key = [0u8; 48];
|
|
@ -464,10 +464,10 @@ impl<EG: EntityGateway> ServerState for ShipServerState<EG> { |
|
|
rng.fill(&mut server_key[..]);
|
|
|
rng.fill(&mut server_key[..]);
|
|
|
rng.fill(&mut client_key[..]);
|
|
|
rng.fill(&mut client_key[..]);
|
|
|
|
|
|
|
|
|
vec![OnConnect::Packet(SendShipPacket::ShipWelcome(ShipWelcome::new(server_key, client_key))),
|
|
|
|
|
|
|
|
|
Ok(vec![OnConnect::Packet(SendShipPacket::ShipWelcome(ShipWelcome::new(server_key, client_key))),
|
|
|
OnConnect::Cipher((Box::new(PSOBBCipher::new(ELSEWHERE_PARRAY, ELSEWHERE_PRIVATE_KEY, client_key)),
|
|
|
OnConnect::Cipher((Box::new(PSOBBCipher::new(ELSEWHERE_PARRAY, ELSEWHERE_PRIVATE_KEY, client_key)),
|
|
|
Box::new(PSOBBCipher::new(ELSEWHERE_PARRAY, ELSEWHERE_PRIVATE_KEY, server_key))))
|
|
|
Box::new(PSOBBCipher::new(ELSEWHERE_PARRAY, ELSEWHERE_PRIVATE_KEY, server_key))))
|
|
|
]
|
|
|
|
|
|
|
|
|
])
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
async fn handle(&mut self, id: ClientId, pkt: &RecvShipPacket)
|
|
|
async fn handle(&mut self, id: ClientId, pkt: &RecvShipPacket)
|
|
@ -577,7 +577,7 @@ impl<EG: EntityGateway> ServerState for ShipServerState<EG> { |
|
|
})
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
async fn on_disconnect(&mut self, id: ClientId) -> Vec<(ClientId, SendShipPacket)> {
|
|
|
|
|
|
|
|
|
async fn on_disconnect(&mut self, id: ClientId) -> Result<Vec<(ClientId, SendShipPacket)>, ShipError> {
|
|
|
// TODO: don't unwrap!
|
|
|
// TODO: don't unwrap!
|
|
|
let client = self.clients.get(&id).unwrap();
|
|
|
let client = self.clients.get(&id).unwrap();
|
|
|
let area_client = self.client_location.get_local_client(id).unwrap();
|
|
|
let area_client = self.client_location.get_local_client(id).unwrap();
|
|
@ -605,9 +605,9 @@ impl<EG: EntityGateway> ServerState for ShipServerState<EG> { |
|
|
self.entity_gateway.save_user(&client.user).await;
|
|
|
self.entity_gateway.save_user(&client.user).await;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
neighbors.into_iter().map(|n| {
|
|
|
|
|
|
|
|
|
Ok(neighbors.into_iter().map(|n| {
|
|
|
(n.client, pkt.clone())
|
|
|
(n.client, pkt.clone())
|
|
|
}).collect()
|
|
|
|
|
|
|
|
|
}).collect())
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|