[][src]Function skyway_webrtc_gateway_api::data::redirect

pub async fn redirect<'_, '_>(
    data_connection_id: &'_ DataConnectionId,
    redirect_data_params: &'_ RedirectDataParams
) -> Result<RedirectDataResponse, Error>

DataConnection is automatically established when neighbour connect to this side. In that case, the connection doesn't have source and destination port information. This function set the information.

Example

use skyway_webrtc_gateway_api::prelude::{DataId, DataConnectionId, PhantomId, SocketInfo, SerializableSocket};
use skyway_webrtc_gateway_api::data::{DataIdWrapper, RedirectDataParams, redirect};

async fn example() {
    let data_connection_id = DataConnectionId::new("dc-example");
    let feed_params = Some(DataIdWrapper {
        data_id: DataId::new("da-example")
    });
    let redirect_params = SocketInfo::<PhantomId>::new(None, "127.0.0.1:8000".parse().unwrap());
    let redirect_params = RedirectDataParams {
        feed_params: feed_params,
        redirect_params: Some(redirect_params)
    };
    let result = redirect(&data_connection_id, &redirect_params).await;
}