connect Local Ips
Connects to a local socket and manages socket events for media consumption.
This function sets up event listeners on the provided local socket for handling new media producers and closed producers. It utilizes the provided methods to manage these events accordingly.
Features:
Registers event handlers on existing socket
Handles 'new-producer' events
Handles 'producer-closed' events
Initializes piped transports for local consumption
Prevents duplicate listener registration
Parameters:
options Configuration options for establishing connections and managing sockets
Returns:
Example Usage:
val options = ConnectLocalIpsOptions(
socket = localSocket,
parameters = connectLocalIpsParametersInstance
)
val result = connectLocalIps(options)
result.onSuccess {
}
result.onFailure { error ->
Logger.e("ConnectLocalIps", "Error connecting to local IPs: ${error.message}")
}Error Handling:
Returns Result.failure if socket is null
Returns Result.success immediately if listeners already registered
Logs errors without throwing exceptions
Implementation Notes:
Checks for existing listeners to avoid duplicates
Uses default implementations if custom methods not provided
Initializes piped transports after event registration
All event handlers run in coroutine scope