connect Ips
Connects to multiple remote IPs to manage socket connections for media consumption.
This function iterates over a list of remote IPs, attempting to establish socket connections and manage events for new media producers and closed producers in the connected rooms. If successful, it updates the consumeSockets list with each connected socket and tracks connected IPs in roomRecvIPs.
Features:
Establishes socket connections to multiple remote IPs
Handles socket events (new-pipe-producer, producer-closed)
Joins consumption rooms for each connected IP
Updates state with connected sockets and IPs
Provides default implementations for event handlers
Parameters:
options Configuration options for establishing connections and managing sockets
Returns:
Result<ConnectIpsResult> containing:
Success: Updated consumeSockets and roomRecvIPs
Failure: Exception with error details
Example Usage:
val options = ConnectIpsOptions(
consumeSockets = emptyList(),
remIP = listOf("100.122.1.1", "100.122.1.2"),
apiUserName = "myUserName",
apiToken = "myToken",
parameters = myConnectIpsParametersInstance
)
val result = connectIps(options)
result.onSuccess { (consumeSockets, roomRecvIPs) ->
}
result.onFailure { error ->
Logger.e("ConnectIps", "Connection failed: ${error.message}")
}Error Handling:
Returns Result.failure if authentication parameters are missing
Logs errors for individual IP connection failures without stopping iteration
Returns partial success if some IPs connect successfully
Implementation Notes:
Skips IPs that are already connected
Skips empty, blank, or "none" IPs
Uses default event handlers if not provided
Each IP connection is attempted independently
Connection timeout: 30 seconds per IP