pub struct VRChatOSC { /* private fields */ }Expand description
Main struct for managing VRChat OSC communication and service discovery.
Implementations§
Source§impl VRChatOSC
impl VRChatOSC
Sourcepub async fn new(osc_ip: Option<IpAddr>) -> Result<Arc<VRChatOSC>, Error>
pub async fn new(osc_ip: Option<IpAddr>) -> Result<Arc<VRChatOSC>, Error>
Creates a new VRChatOSC instance.
§Arguments
osc_ip- Optional destination IP address for OSC messages. IfNone, it will attempt to automatically find a suitable network interface.
Sourcepub async fn get_osc_ip(&self) -> IpAddr
pub async fn get_osc_ip(&self) -> IpAddr
Gets the currently configured OSC destination IP address.
Sourcepub async fn on_connect<F>(&self, callback: F)
pub async fn on_connect<F>(&self, callback: F)
Registers a callback to be invoked when a new OSC service is discovered on the network.
§Arguments
callback- A function or closure called with the discovered service details.
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 local OSC service to be discoverable by other clients.
§Arguments
service_name- The name of the service to register.parameters- The OSC address space and parameters for this service.handler- A function called when an OSC packet is received for this service.
Sourcepub async fn unregister(&self, service_name: &str) -> Result<(), Error>
pub async fn unregister(&self, service_name: &str) -> Result<(), Error>
Unregisters an OSC service and stops its servers.
§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 name pattern.
§Arguments
packet- TheOscPacketto send.to- A pattern (e.g., “VRChat-Client-*”) to match against discovered service names.
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 parameter from services matching a name pattern.
§Arguments
method- The OSC path of the parameter (e.g., “/avatar/parameters/MyParam”).from- A pattern (e.g., “VRChat-Client-*”) to match against discovered service names.
§Returns
A list of matching service names and their corresponding parameter values.
Sourcepub async fn get_parameter_from_addr(
&self,
method: &str,
addr: SocketAddr,
) -> Result<OscNode, Error>
pub async fn get_parameter_from_addr( &self, method: &str, addr: SocketAddr, ) -> Result<OscNode, Error>
Sourcepub async fn shutdown(&self) -> Result<(), Error>
pub async fn shutdown(&self) -> Result<(), Error>
Shuts down all registered services and cleans up resources. This method should be called before the VRChatOSC instance is dropped to ensure graceful shutdown of asynchronous tasks and network services.
Sourcepub async fn list_services(&self) -> Vec<String>
pub async fn list_services(&self) -> Vec<String>
Lists the names of all currently registered services.