Compare commits
6 Commits
543fbd1ab1
...
938dce6061
Author | SHA1 | Date |
---|---|---|
kozabrada123 | 938dce6061 | |
kozabrada123 | a27b488f61 | |
kozabrada123 | d829537713 | |
kozabrada123 | b9bc37fcd4 | |
kozabrada123 | 832576dbf4 | |
kozabrada123 | 539460a552 |
|
@ -34,8 +34,13 @@ use wasmtimer::tokio::sleep;
|
|||
#[derive(Debug)]
|
||||
pub struct ExampleObserver {}
|
||||
|
||||
// This struct can observe GatewayReady events when subscribed, because it implements the trait Observer<GatewayReady>.
|
||||
// The Observer trait can be implemented for a struct for a given websocketevent to handle observing it
|
||||
// This struct can observe GatewayReady events when subscribed, because it implements the trait Subscriber<GatewayReady>.
|
||||
// The Subscriber trait can be implemented for a struct for a given websocketevent to handle observing it
|
||||
//
|
||||
// Note that this trait is quite generic and can be use to observe any type.
|
||||
//
|
||||
// It is just used for WebSocketEvents in chorus.
|
||||
//
|
||||
// One struct can be an observer of multiple websocketevents, if needed
|
||||
#[async_trait]
|
||||
impl Subscriber<GatewayReady> for ExampleObserver {
|
||||
|
|
|
@ -22,11 +22,9 @@ use simplelog::{TermLogger, Config, WriteLogger};
|
|||
use std::{net::SocketAddrV4, sync::Arc, fs::File, time::Duration};
|
||||
|
||||
use chorus::{
|
||||
gateway::{Observer, Gateway},
|
||||
gateway::{Gateway, GatewayOptions, Observer},
|
||||
types::{
|
||||
GatewayReady, SelectProtocol, SelectProtocolData, SessionDescription, Snowflake, Speaking,
|
||||
SpeakingBitflags, SsrcDefinition, VoiceEncryptionMode, VoiceIdentify, VoiceProtocol,
|
||||
VoiceReady, VoiceServerUpdate, GatewayIdentifyPayload, UpdateVoiceState,
|
||||
GatewayIdentifyPayload, GatewayReady, SelectProtocol, SelectProtocolData, SessionDescription, Snowflake, Speaking, SpeakingBitflags, SsrcDefinition, UpdateVoiceState, VoiceEncryptionMode, VoiceIdentify, VoiceProtocol, VoiceReady, VoiceServerUpdate
|
||||
},
|
||||
voice::{
|
||||
gateway::{VoiceGateway, VoiceGatewayHandle},
|
||||
|
@ -219,7 +217,7 @@ impl Observer<Speaking> for VoiceHandler {
|
|||
println!(
|
||||
"Received Speaking! (SRRC: {}, flags: {:?})",
|
||||
data.ssrc,
|
||||
SpeakingBitflags::from_bits(data.speaking).unwrap()
|
||||
SpeakingBitflags::from_bits(data.speaking.into()).unwrap()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -253,7 +251,7 @@ async fn main() {
|
|||
])
|
||||
.unwrap();
|
||||
|
||||
let gateway = Gateway::spawn(GATEWAY_URL.to_string())
|
||||
let gateway = Gateway::spawn(GATEWAY_URL.to_string(), GatewayOptions::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ pub use message::*;
|
|||
pub use options::*;
|
||||
|
||||
use crate::errors::GatewayError;
|
||||
use crate::types::{Snowflake};
|
||||
use crate::types::Snowflake;
|
||||
|
||||
use std::any::Any;
|
||||
use std::collections::HashMap;
|
||||
|
@ -77,6 +77,10 @@ const GATEWAY_LAZY_REQUEST: u8 = 14;
|
|||
|
||||
pub type ObservableObject = dyn Send + Sync + Any;
|
||||
|
||||
/// Note: this is a reexport of [pubserve::Subscriber],
|
||||
/// exported not to break the public api and make development easier
|
||||
pub use pubserve::Subscriber as Observer;
|
||||
|
||||
/// An entity type which is supposed to be updateable via the Gateway. This is implemented for all such types chorus supports, implementing it for your own types is likely a mistake.
|
||||
pub trait Updateable: 'static + Send + Sync {
|
||||
fn id(&self) -> Snowflake;
|
||||
|
|
Loading…
Reference in New Issue