[−][src]Struct mixer_wrappers::chat::ChatClient
Wrapper for connecting and interacting with the chat server.
Fields
join_handle: JoinHandle<()>
Internal thread join handle
Implementations
impl ChatClient
[src]
pub fn connect(
endpoint: &str,
client_id: &str
) -> Result<(Self, Receiver<String>), Error>
[src]
endpoint: &str,
client_id: &str
) -> Result<(Self, Receiver<String>), Error>
Connect to the chat server.
Per the documentation, connecting to the chat server isn't as straightforward as connecting to Constellation, as the client must first make a call to the REST API to fetch information about the chat connection, including the endpoint to connect to. This function does not handle that process; use the REST API included in this crate to get that information.
Arguments
endpoint
- chat websocket endpoint to connect toclient_id
- your client ID
Examples
use mixer_wrappers::ChatClient; let (mut client, receiver) = ChatClient::connect("aaa", "bbb").unwrap();
pub fn authenticate(
&mut self,
channel_id: usize,
user_id: Option<usize>,
auth_key: Option<&str>
) -> Result<(), Error>
[src]
&mut self,
channel_id: usize,
user_id: Option<usize>,
auth_key: Option<&str>
) -> Result<(), Error>
Authenticate with the server. This must be done after connecting.
Per the documentation, you can either authenticate anonymously,
or as an actual user. The former is done by passing this function
None
s for the second and third parameters.
Arguments
channel_id
- channel to connect to, fetched from the REST APIuser_id
- Option of user to auth asauth_key
- Option of user key to use
Examples
if let Err(e) = client.authenticate(123, Some(456), Some("ccc")) { // ... }
pub fn call_method(
&mut self,
method: &str,
arguments: &[Value]
) -> Result<(), Error>
[src]
&mut self,
method: &str,
arguments: &[Value]
) -> Result<(), Error>
Call a method, sending data to the socket.
The arguments
parameter is so dynamic because while the arguments
parameter is an array, it's JSON, so there can be any number of elements
in the array of different types.
Arguments
method
- method namearguments
- method arguments
Examples
if let Err(e) = client.call_method("some_method", &[json!(123), json!("abc")]) { // ... }
pub fn parse(message: &str) -> Result<StreamMessage, Error>
[src]
Auto Trait Implementations
impl !RefUnwindSafe for ChatClient
impl Send for ChatClient
impl !Sync for ChatClient
impl Unpin for ChatClient
impl !UnwindSafe for ChatClient
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
U: TryFrom<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,