diff options
Diffstat (limited to 'azalea-client/src/client.rs')
| -rw-r--r-- | azalea-client/src/client.rs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs index 09f68c4a..25c68c5d 100644 --- a/azalea-client/src/client.rs +++ b/azalea-client/src/client.rs @@ -38,7 +38,6 @@ use std::{ }; use thiserror::Error; use tokio::{ - io::AsyncWriteExt, sync::mpsc::{self, UnboundedReceiver, UnboundedSender}, task::JoinHandle, time::{self}, @@ -105,6 +104,8 @@ pub enum JoinError { ReadPacket(#[from] azalea_protocol::read::ReadPacketError), #[error("{0}")] Io(#[from] io::Error), + #[error("{0}")] + SessionServer(#[from] azalea_auth::sessionserver::SessionServerError), } #[derive(Error, Debug)] @@ -159,7 +160,17 @@ impl Client { debug!("Got encryption request"); let e = azalea_crypto::encrypt(&p.public_key, &p.nonce).unwrap(); - // TODO: authenticate with the server here (authenticateServer) + if let Some(access_token) = &account.access_token { + conn.authenticate( + access_token, + &account + .uuid + .expect("Uuid must be present if access token is present."), + e.secret_key, + p, + ) + .await?; + } conn.write( ServerboundKeyPacket { @@ -171,6 +182,7 @@ impl Client { .get(), ) .await?; + conn.set_encryption_key(e.secret_key); } ClientboundLoginPacket::LoginCompression(p) => { @@ -237,7 +249,7 @@ impl Client { /// Disconnect from the server, ending all tasks. pub async fn shutdown(self) -> Result<(), std::io::Error> { - self.write_conn.lock().await.write_stream.shutdown().await?; + self.write_conn.lock().await.shutdown().await?; let tasks = self.tasks.lock(); for task in tasks.iter() { task.abort(); |
