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

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, SerializableId};
use skyway_webrtc_gateway_api::data::{DataIdWrapper, RedirectDataParams, redirect};

async fn example() {
    let data_connection_id = DataConnectionId::try_create("dc-4995f372-fb6a-4196-b30a-ce11e5c7f56c").unwrap();
    let feed_params = Some(DataIdWrapper {
        data_id: DataId::try_create("da-50a32bab-b3d9-4913-8e20-f79c90a6a211").unwrap()
    });
    let redirect_params = SocketInfo::<PhantomId>::try_create(None, "127.0.0.1", 8000).unwrap();
    let redirect_params = RedirectDataParams {
        feed_params: feed_params,
        redirect_params: Some(redirect_params)
    };
    let result = redirect(&data_connection_id, &redirect_params).await;
}