pub struct VRChatOSC { /* private fields */ }Expand description
Main struct for managing VRChat OSC services, discovery, and communication.
Implementations§
Source§impl VRChatOSC
impl VRChatOSC
Sourcepub async fn new() -> Result<Arc<VRChatOSC>, Error>
pub async fn new() -> Result<Arc<VRChatOSC>, Error>
Creates a new VRChatOSC instance.
Initializes mDNS, sets up service discovery, and starts a listener task for mDNS service notifications.
Sourcepub async fn on_connect<F>(&self, callback: F)
pub async fn on_connect<F>(&self, callback: F)
Registers a callback function to be invoked when an mDNS service is discovered.
§Arguments
callback- A function or closure that takes the serviceNameandSocketAddras arguments. It must beSend + Sync + 'static.
Sourcepub async fn register<F>(
&self,
service_name: &str,
parameters: OscRootNode,
handler: F,
) -> Result<(), Error>
pub async fn register<F>( &self, service_name: &str, parameters: OscRootNode, handler: F, ) -> Result<(), Error>
Registers a new OSC service with the local mDNS daemon and starts listening for OSC messages.
§Arguments
service_name- The name of the service to register (e.g., “MyAppOSC”).parameters- The root node of the OSC address space for this service.handler- A function that will be called when an OSC packet is received for this service. It must beFn(OscPacket) + Send + 'static.
Sourcepub async fn unregister(&self, service_name: &str) -> Result<(), Error>
pub async fn unregister(&self, service_name: &str) -> Result<(), Error>
Unregisters an OSC service. Stops the OSC and OSCQuery servers and removes mDNS announcements.
§Arguments
service_name- The name of the service to unregister.
Sourcepub async fn send(&self, packet: OscPacket, to: &str) -> Result<(), Error>
pub async fn send(&self, packet: OscPacket, to: &str) -> Result<(), Error>
Sends an OSC packet to services matching a given pattern.
§Arguments
packet- TheOscPacketto send.to- A glob pattern (e.g., “VRChat-Client-*”) to match against service names. This matches against the service instance name found via mDNS.
Sourcepub async fn send_to_addr(
&self,
packet: OscPacket,
addr: SocketAddr,
) -> Result<(), Error>
pub async fn send_to_addr( &self, packet: OscPacket, addr: SocketAddr, ) -> Result<(), Error>
Sends an OSC packet to a specific socket address.
§Arguments
packet- TheOscPacketto send.addr- TheSocketAddrto send the packet to.
Sourcepub async fn get_parameter(
&self,
method: &str,
from: &str,
) -> Result<Vec<(Name, OscNode)>, Error>
pub async fn get_parameter( &self, method: &str, from: &str, ) -> Result<Vec<(Name, OscNode)>, Error>
Retrieves a specific OSC parameter (node) from services matching a pattern.
§Arguments
method- The OSC path of the parameter to fetch (e.g., “/avatar/parameters/SomeParam”).from- A glob pattern (e.g., “VRChat-Client-*”) to match against service names. This matches against the service instance name found via mDNS.
§Returns
A Vec of tuples, where each tuple contains the service Name and the fetched OscNode.
Returns an empty Vec if no services match or if fetching fails for all matched services.