pub struct WaapiClient { /* private fields */ }Expand description
Async WAAPI client.
Provides async access to the Wwise Authoring API (WAAPI); can be shared across tasks (internal Arc).
It is recommended to call disconnect explicitly
for graceful shutdown.
WAAPI 异步客户端。
建议显式调用 disconnect 以确保优雅关闭。
Implementations§
Source§impl WaapiClient
impl WaapiClient
Sourcepub async fn connect() -> Result<Self, WaapiError>
pub async fn connect() -> Result<Self, WaapiError>
Connect to WAAPI using the default URL.
Connects to ws://localhost:8080/waapi with the default realm.
使用默认 URL 连接到 WAAPI。
Sourcepub async fn connect_with_url(url: &str) -> Result<Self, WaapiError>
pub async fn connect_with_url(url: &str) -> Result<Self, WaapiError>
Connect to WAAPI at the specified URL.
使用指定 URL 连接到 WAAPI。
Sourcepub async fn call(
&self,
uri: &str,
args: Option<Value>,
options: Option<Value>,
) -> Result<Option<Value>, WaapiError>
pub async fn call( &self, uri: &str, args: Option<Value>, options: Option<Value>, ) -> Result<Option<Value>, WaapiError>
Call a WAAPI method.
§Parameters
uri- URI of the WAAPI method, e.g."ak.wwise.core.getInfo"orak::wwise::core::GET_INFOargs- Optional keyword arguments (serde_json::Value, e.g.json!({...}))options- Optional options dict (serde_json::Value)
Returns Option<Value>: WAAPI response as JSON; None when no result.
调用 WAAPI 方法。
返回 Option<Value>:WAAPI 响应的 JSON 值;无结果时为 None。
Sourcepub async fn subscribe<F>(
&self,
topic: &str,
options: Option<Value>,
callback: F,
) -> Result<SubscriptionHandle, WaapiError>
pub async fn subscribe<F>( &self, topic: &str, options: Option<Value>, callback: F, ) -> Result<SubscriptionHandle, WaapiError>
Subscribe to a topic with a callback.
The callback runs in a dedicated task with signature callback(kwargs).
The returned handle is used to cancel; on drop it auto-unsubscribes.
§Parameters
topic- WAMP topic URIoptions- Optional subscription options (serde_json::Value)callback- Callback invoked on each event withkwargs(Option<Value>)
订阅主题并绑定回调(参数为 Option<Value>)。
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Check whether the client is still connected.
检查客户端是否仍处于连接状态。
Sourcepub async fn disconnect(self)
pub async fn disconnect(self)
Explicitly disconnect.
Explicit call is recommended for graceful shutdown.
显式断开连接。推荐显式调用以确保优雅关闭。