pub async fn new(url: String) -> Result<ReplicationWasm, JsError> {
        // Connect websocket.
        let (meta, ws) = WsMeta::connect(url, None).await?;
        let stream = ws.into_io();

        // Handshake
        let t = async move {
            Delay::new(Duration::from_secs(5)).await.unwrap();
            Err(JsError::new("Handshake timed out."))
        };
        let replication = async move {
            let options = Options {
                is_initiator: true,
                keepalive_ms: None,
                ..Options::default()
            };
            Replication::with_options(stream, options)
                .await.map_err(|_| JsError::new("Handshake error."))
        };
        let (replication, handle) = race(t, replication).await?;

        Ok(Self {
            replication,
            meta,
            handle,
        })
    }
/// Create, connect, and handshake a new websocket [Replication].
Create, connect, and handshake a new websocket [Replication].
Create connect and handshake a new websocket [ Replication ] .
pub async fn new(url: String) -> Result<ReplicationWasm, JsError> {
        // Connect websocket.
        let (meta, ws) = WsMeta::connect(url, None).await?;
        let stream = ws.into_io();
        // Handshake
        let t = async move {
            Delay::new(Duration::from_secs(5)).await.unwrap();
            Err(JsError::new("Handshake timed out."))
        };
        let replication = async move {
            let options = Options {
                is_initiator: true,
                keepalive_ms: None,
                ..Options::default()
            };
            Replication::with_options(stream, options)
                .await.map_err(|_| JsError::new("Handshake error."))
        };
        let (replication, handle) = race(t, replication).await?;
        Ok(Self {
            replication,
            meta,
            handle,
        })
    }
pub async fn new ( url : String ) -> Result < ReplicationWasm , JsError > { // Connect websocket. let ( meta , ws ) = WsMeta :: connect ( url , None ) . await ? ; let stream = ws . into_io ( ) ; // Handshake let t = async move { Delay :: new ( Duration :: from_secs ( 5 ) ) . await . unwrap ( ) ; Err ( JsError :: new ( " " ) ) } ; let replication = async move { let options = Options { is_initiator : true , keepalive_ms : None , .. Options :: default ( ) } ; Replication :: with_options ( stream , options ) . await . map_err ( | _ | JsError :: new ( " " ) ) } ; let ( replication , handle ) = race ( t , replication ) . await ? ; Ok ( Self { replication , meta , handle , } ) }
Create, connect, and handshake a new websocket [Replication].
Create connect and handshake a new websocket [ Replication ] .
url
String
url
String