pub async fn connect(
        uri: &url::Url,
        cfg: &client::ClientConfig,
        ctl_channel: (UnboundedSender<Request<'a>>, UnboundedReceiver<Request<'a>>),
        core_res: UnboundedSender<Result<(), WampError>>,
    ) -> Result<Core<'a>, WampError> {
        // Connect to the router using the requested transport
        let (sock, serializer_type) = match uri.scheme() {
            "ws" | "wss" => ws::connect(uri, &cfg).await?,
            "tcp" | "tcps" => {
                let host_port = match uri.port() {
                    Some(p) => p,
                    None => {
                        return Err(From::from("No port specified for tcp host".to_string()));
                    }
                };

                // Perform the TCP connection
                tcp::connect(
                    uri.host_str().unwrap(),
                    host_port,
                    uri.scheme() != "tcp",
                    &cfg,
                )
                .await?
            }
            s => return Err(From::from(format!("Unknown uri scheme : {}", s))),
        };

        debug!("Connected with serializer : {:?}", serializer_type);

        let serializer: Box<dyn SerializerImpl + Send> = match serializer_type {
            SerializerType::Json => Box::new(json::JsonSerializer {}),
            SerializerType::MsgPack => Box::new(msgpack::MsgPackSerializer {}),
        };

        //let (rpc_result_w, rpc_result_r) = mpsc::unbounded_channel();
        let (rpc_event_queue_w, rpc_event_queue_r) = mpsc::unbounded_channel();

        Ok(Core {
            sock,
            core_res,
            valid_session: false,
            serializer,
            ctl_sender: ctl_channel.0,
            ctl_channel: Some(ctl_channel.1),
            pending_requests: HashSet::new(),
            pending_transactions: HashMap::new(),

            pending_sub: HashMap::new(),
            subscriptions: HashMap::new(),

            pending_register: HashMap::new(),
            rpc_endpoints: HashMap::new(),
            rpc_event_queue_r: Some(rpc_event_queue_r),
            rpc_event_queue_w,
            pending_call: HashMap::new(),
        })
    }
/// Establishes a connection with a WAMP server
Establishes a connection with a WAMP server
Establishes a connection with a WAMP server
pub async fn connect(
        uri: &url::Url,
        cfg: &client::ClientConfig,
        ctl_channel: (UnboundedSender<Request<'a>>, UnboundedReceiver<Request<'a>>),
        core_res: UnboundedSender<Result<(), WampError>>,
    ) -> Result<Core<'a>, WampError> {
        // Connect to the router using the requested transport
        let (sock, serializer_type) = match uri.scheme() {
            "ws" | "wss" => ws::connect(uri, &cfg).await?,
            "tcp" | "tcps" => {
                let host_port = match uri.port() {
                    Some(p) => p,
                    None => {
                        return Err(From::from("No port specified for tcp host".to_string()));
                    }
                };
                // Perform the TCP connection
                tcp::connect(
                    uri.host_str().unwrap(),
                    host_port,
                    uri.scheme() != "tcp",
                    &cfg,
                )
                .await?
            }
            s => return Err(From::from(format!("Unknown uri scheme : {}", s))),
        };
        debug!("Connected with serializer : {:?}", serializer_type);
        let serializer: Box<dyn SerializerImpl + Send> = match serializer_type {
            SerializerType::Json => Box::new(json::JsonSerializer {}),
            SerializerType::MsgPack => Box::new(msgpack::MsgPackSerializer {}),
        };
        //let (rpc_result_w, rpc_result_r) = mpsc::unbounded_channel();
        let (rpc_event_queue_w, rpc_event_queue_r) = mpsc::unbounded_channel();
        Ok(Core {
            sock,
            core_res,
            valid_session: false,
            serializer,
            ctl_sender: ctl_channel.0,
            ctl_channel: Some(ctl_channel.1),
            pending_requests: HashSet::new(),
            pending_transactions: HashMap::new(),
            pending_sub: HashMap::new(),
            subscriptions: HashMap::new(),
            pending_register: HashMap::new(),
            rpc_endpoints: HashMap::new(),
            rpc_event_queue_r: Some(rpc_event_queue_r),
            rpc_event_queue_w,
            pending_call: HashMap::new(),
        })
    }
pub async fn connect ( uri : & url :: Url , cfg : & client :: ClientConfig , ctl_channel : ( UnboundedSender < Request < ' a > > , UnboundedReceiver < Request < ' a > > ) , core_res : UnboundedSender < Result < ( ) , WampError > > , ) -> Result < Core < ' a > , WampError > { // Connect to the router using the requested transport let ( sock , serializer_type ) = match uri . scheme ( ) { " " | " " => ws :: connect ( uri , & cfg ) . await ? , " " | " " => { let host_port = match uri . port ( ) { Some ( p ) => p , None => { return Err ( From :: from ( " " . to_string ( ) ) ) ; } } ; // Perform the TCP connection tcp :: connect ( uri . host_str ( ) . unwrap ( ) , host_port , uri . scheme ( ) != " " , & cfg , ) . await ? } s => return Err ( From :: from ( format ! ( " " s ) ) ) , } ; debug ! ( " " serializer_type ) ; let serializer : Box < dyn SerializerImpl + Send > = match serializer_type { SerializerType :: Json => Box :: new ( json :: JsonSerializer { } ) , SerializerType :: MsgPack => Box :: new ( msgpack :: MsgPackSerializer { } ) , } ; //let (rpc_result_w, rpc_result_r) = mpsc::unbounded_channel(); let ( rpc_event_queue_w , rpc_event_queue_r ) = mpsc :: unbounded_channel ( ) ; Ok ( Core { sock , core_res , valid_session : false , serializer , ctl_sender : ctl_channel . 0 , ctl_channel : Some ( ctl_channel . 1 ) , pending_requests : HashSet :: new ( ) , pending_transactions : HashMap :: new ( ) , pending_sub : HashMap :: new ( ) , subscriptions : HashMap :: new ( ) , pending_register : HashMap :: new ( ) , rpc_endpoints : HashMap :: new ( ) , rpc_event_queue_r : Some ( rpc_event_queue_r ) , rpc_event_queue_w , pending_call : HashMap :: new ( ) , } ) }
Establishes a connection with a WAMP server
Establishes a connection with a WAMP server
uri
&url::Url
cfg
&client::ClientConfig
ctl_channel
(UnboundedSender<Request<'a>>, UnboundedReceiver<Request<'a>>)
core_res
UnboundedSender<Result<(), WampError>>