Merge pull request #6 from DylanCa/develop
This commit is contained in:
commit
b1e55ed27a
2 changed files with 12 additions and 2 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "rust-discord-activity"
|
name = "rust-discord-activity"
|
||||||
description = "A lightweight library to control Discord Rich Presence"
|
description = "A lightweight library to control Discord Rich Presence"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["Dylan Cattelan <dylan.cattelan@gmail.com"]
|
authors = ["Dylan Cattelan <dylan.cattelan@gmail.com"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,11 @@ use crate::models::error::Error::DiscordNotFound;
|
||||||
pub struct DiscordClient {
|
pub struct DiscordClient {
|
||||||
/// ID of Discord Application, see <https://discord.com/developers> for more info
|
/// ID of Discord Application, see <https://discord.com/developers> for more info
|
||||||
pub id: String,
|
pub id: String,
|
||||||
|
|
||||||
|
/// Boolean stating if Client is connected to Discord App.
|
||||||
|
pub is_connected: bool,
|
||||||
|
|
||||||
|
/// Unix Stream socket of Client Connection.
|
||||||
socket: Option<UnixStream>,
|
socket: Option<UnixStream>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -23,6 +28,7 @@ impl DiscordClient {
|
||||||
pub fn new(id: &str) -> Self {
|
pub fn new(id: &str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
id: id.to_string(),
|
id: id.to_string(),
|
||||||
|
is_connected: false,
|
||||||
socket: None,
|
socket: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -35,9 +41,13 @@ impl DiscordClient {
|
||||||
Ok(socket) => {
|
Ok(socket) => {
|
||||||
self.socket = Some(socket);
|
self.socket = Some(socket);
|
||||||
self.handshake().expect("Could not handshake.");
|
self.handshake().expect("Could not handshake.");
|
||||||
|
self.is_connected = true;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Err(_) => Err(DiscordNotFound),
|
Err(_) => {
|
||||||
|
self.is_connected = false;
|
||||||
|
Err(DiscordNotFound)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue