diff options
| author | Maiddog <[email protected]> | 2017-08-26 17:55:43 -0500 |
|---|---|---|
| committer | alex <[email protected]> | 2017-08-27 00:55:43 +0200 |
| commit | 3e0b1032d80a1847558a752e8316d97f9ae58f04 (patch) | |
| tree | ca65390091cb3c0ab98b6497a1447ba69df3d20d /src/client/mod.rs | |
| parent | Use `$crate` for `Args` (diff) | |
| download | serenity-3e0b1032d80a1847558a752e8316d97f9ae58f04.tar.xz serenity-3e0b1032d80a1847558a752e8316d97f9ae58f04.zip | |
Add ability to play DCA and Opus files. (#148)
Diffstat (limited to 'src/client/mod.rs')
| -rw-r--r-- | src/client/mod.rs | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/client/mod.rs b/src/client/mod.rs index 47ff96c..5821597 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -37,7 +37,7 @@ pub use CACHE; use self::dispatch::dispatch; use std::sync::{self, Arc}; -use std::sync::atomic::{AtomicBool, Ordering, ATOMIC_BOOL_INIT}; +use std::sync::atomic::{ATOMIC_BOOL_INIT, AtomicBool, Ordering}; use parking_lot::Mutex; use tokio_core::reactor::Core; use futures; @@ -194,7 +194,8 @@ pub struct Client<H: EventHandler + 'static> { /// [`Event::Ready`]: ../model/event/enum.Event.html#variant.Ready /// [`on_ready`]: #method.on_ready event_handler: Arc<H>, - #[cfg(feature = "framework")] framework: Arc<sync::Mutex<Option<Box<Framework>>>>, + #[cfg(feature = "framework")] + framework: Arc<sync::Mutex<Option<Box<Framework>>>>, token: Arc<sync::Mutex<String>>, } @@ -354,7 +355,7 @@ impl<H: EventHandler + 'static> Client<H> { /// [`on_message`]: #method.on_message /// [framework docs]: ../framework/index.html #[cfg(feature = "framework")] -pub fn with_framework<F: Framework + 'static>(&mut self, f: F){ + pub fn with_framework<F: Framework + 'static>(&mut self, f: F) { self.framework = Arc::new(sync::Mutex::new(Some(Box::new(f)))); } @@ -539,7 +540,10 @@ pub fn with_framework<F: Framework + 'static>(&mut self, f: F){ /// [`start_autosharded`]: #method.start_autosharded /// [gateway docs]: gateway/index.html#sharding pub fn start_shard(&mut self, shard: u64, shards: u64) -> Result<()> { - self.start_connection([shard, shard, shards], http::get_gateway()?.url) + self.start_connection( + [shard, shard, shards], + http::get_gateway()?.url, + ) } /// Establish sharded connections and start listening for events. @@ -664,7 +668,10 @@ pub fn with_framework<F: Framework + 'static>(&mut self, f: F){ /// [`start_shards`]: #method.start_shards /// [Gateway docs]: gateway/index.html#sharding pub fn start_shard_range(&mut self, range: [u64; 2], total_shards: u64) -> Result<()> { - self.start_connection([range[0], range[1], total_shards], http::get_gateway()?.url) + self.start_connection( + [range[0], range[1], total_shards], + http::get_gateway()?.url, + ) } /// Returns a thread-safe handle for closing shards. @@ -722,7 +729,8 @@ pub fn with_framework<F: Framework + 'static>(&mut self, f: F){ Ok(shard) => { let shard = Arc::new(Mutex::new(shard)); - let monitor_info = feature_framework! {{ + let monitor_info = + feature_framework! {{ MonitorInfo { data: self.data.clone(), event_handler: self.event_handler.clone(), @@ -838,7 +846,7 @@ fn boot_shard(info: &BootInfo) -> Result<Shard> { Err(Error::Client(ClientError::ShardBootFailure)) } -fn monitor_shard<H: EventHandler + 'static>(mut info: MonitorInfo<H>){ +fn monitor_shard<H: EventHandler + 'static>(mut info: MonitorInfo<H>) { handle_shard(&mut info); let mut handle_still = HANDLE_STILL.load(Ordering::Relaxed); @@ -892,7 +900,7 @@ fn monitor_shard<H: EventHandler + 'static>(mut info: MonitorInfo<H>){ } } -fn handle_shard<H: EventHandler + 'static>(info: &mut MonitorInfo<H>){ +fn handle_shard<H: EventHandler + 'static>(info: &mut MonitorInfo<H>) { let mut core = Core::new().unwrap(); let handle = core.handle(); |