pub struct WasmClient { /* private fields */ }Implementations§
Source§impl WasmClient
impl WasmClient
Sourcepub fn session_id(&self) -> String
pub fn session_id(&self) -> String
Return the session id as hex.
Sourcepub fn encode_text(&mut self, text: String) -> Result<Uint8Array, JsValue>
pub fn encode_text(&mut self, text: String) -> Result<Uint8Array, JsValue>
Encode a text message into an encrypted Rift frame.
Sourcepub fn decode_text(&self, bytes: Uint8Array) -> Result<JsValue, JsValue>
pub fn decode_text(&self, bytes: Uint8Array) -> Result<JsValue, JsValue>
Decode an encrypted Rift frame into a JSON-compatible JS object.
Sourcepub fn encode_voice(
&mut self,
opus_payload: Uint8Array,
) -> Result<Uint8Array, JsValue>
pub fn encode_voice( &mut self, opus_payload: Uint8Array, ) -> Result<Uint8Array, JsValue>
Encode a voice frame into an encrypted Rift frame.
The opus_payload should be pre-encoded Opus data from a browser
Opus encoder (e.g., via AudioWorklet + opus-wasm).
Sourcepub fn encode_voice_pcm(
&mut self,
pcm_samples: Uint8Array,
) -> Result<Uint8Array, JsValue>
pub fn encode_voice_pcm( &mut self, pcm_samples: Uint8Array, ) -> Result<Uint8Array, JsValue>
Encode a voice frame with raw PCM16 samples.
Use this when you have raw Int16Array samples from Web Audio API. The samples will be wrapped in a PCM16 codec frame.
Sourcepub fn decode_voice(&self, bytes: Uint8Array) -> Result<JsValue, JsValue>
pub fn decode_voice(&self, bytes: Uint8Array) -> Result<JsValue, JsValue>
Decode an encrypted Rift voice frame.
Returns a JS object with: from, timestamp, seq, codec, payload. The payload is the encoded audio data (Opus or PCM16).
Sourcepub fn extract_voice_payload(
&self,
bytes: Uint8Array,
) -> Result<Uint8Array, JsValue>
pub fn extract_voice_payload( &self, bytes: Uint8Array, ) -> Result<Uint8Array, JsValue>
Get the voice payload bytes from a decoded frame.
This is a convenience method for extracting just the audio payload without the metadata, useful for feeding directly to a decoder.
Trait Implementations§
Source§impl From<WasmClient> for JsValue
impl From<WasmClient> for JsValue
Source§fn from(value: WasmClient) -> Self
fn from(value: WasmClient) -> Self
Source§impl FromWasmAbi for WasmClient
impl FromWasmAbi for WasmClient
Source§impl IntoWasmAbi for WasmClient
impl IntoWasmAbi for WasmClient
Source§impl LongRefFromWasmAbi for WasmClient
impl LongRefFromWasmAbi for WasmClient
Source§impl OptionFromWasmAbi for WasmClient
impl OptionFromWasmAbi for WasmClient
Source§impl OptionIntoWasmAbi for WasmClient
impl OptionIntoWasmAbi for WasmClient
Source§impl RefFromWasmAbi for WasmClient
impl RefFromWasmAbi for WasmClient
Source§type Anchor = RcRef<WasmClient>
type Anchor = RcRef<WasmClient>
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§impl RefMutFromWasmAbi for WasmClient
impl RefMutFromWasmAbi for WasmClient
Source§impl TryFromJsValue for WasmClient
impl TryFromJsValue for WasmClient
Source§impl VectorFromWasmAbi for WasmClient
impl VectorFromWasmAbi for WasmClient
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[WasmClient]>
Source§impl VectorIntoWasmAbi for WasmClient
impl VectorIntoWasmAbi for WasmClient
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[WasmClient]>) -> Self::Abi
Source§impl WasmDescribeVector for WasmClient
impl WasmDescribeVector for WasmClient
impl SupportsConstructor for WasmClient
impl SupportsInstanceProperty for WasmClient
impl SupportsStaticProperty for WasmClient
Auto Trait Implementations§
impl Freeze for WasmClient
impl RefUnwindSafe for WasmClient
impl Send for WasmClient
impl Sync for WasmClient
impl Unpin for WasmClient
impl UnwindSafe for WasmClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.