pub fn connect<OUT: 'static>(
        url: &str,
        callback: Callback<OUT>,
        notification: Callback<WebSocketStatus>,
    ) -> Result<WebSocketTask, WebSocketError>
    where
        OUT: From<Text> + From<Binary>,
    {
        let ConnectCommon(ws, listeners) = Self::connect_common(url, &notification)?;
        let listener = EventListener::new(&ws, "message", move |event: &Event| {
            let event = event.dyn_ref::<MessageEvent>().unwrap();
            process_both(&event, &callback);
        });
        Ok(WebSocketTask::new(ws, notification, listener, listeners))
    }
/// Connects to a server through a WebSocket connection. Needs two callbacks; one is passed
/// data, the other is passed updates about the WebSocket's status.
Connects to a server through a WebSocket connection. Needs two callbacks; one is passed
data, the other is passed updates about the WebSocket's status.
Connects to a server through a WebSocket connection . Needs two callbacks ; one is passed data the other is passed updates about the WebSocket ' s status .
pub fn connect<OUT: 'static>(
        url: &str,
        callback: Callback<OUT>,
        notification: Callback<WebSocketStatus>,
    ) -> Result<WebSocketTask, WebSocketError>
    where
        OUT: From<Text> + From<Binary>,
    {
        let ConnectCommon(ws, listeners) = Self::connect_common(url, &notification)?;
        let listener = EventListener::new(&ws, "message", move |event: &Event| {
            let event = event.dyn_ref::<MessageEvent>().unwrap();
            process_both(&event, &callback);
        });
        Ok(WebSocketTask::new(ws, notification, listener, listeners))
    }
pub fn connect < OUT : ' static > ( url : & str , callback : Callback < OUT > , notification : Callback < WebSocketStatus > , ) -> Result < WebSocketTask , WebSocketError > where OUT : From < Text > + From < Binary > , { let ConnectCommon ( ws , listeners ) = Self :: connect_common ( url , & notification ) ? ; let listener = EventListener :: new ( & ws , " " , move | event : & Event | { let event = event . dyn_ref :: < MessageEvent > ( ) . unwrap ( ) ; process_both ( & event , & callback ) ; } ) ; Ok ( WebSocketTask :: new ( ws , notification , listener , listeners ) ) }
Connects to a server through a WebSocket connection.
Connects to a server through a WebSocket connection .
url
&str
callback
Callback<OUT>
notification
Callback<WebSocketStatus>
url
&str
callback
Callback<OUT>
notification
Callback<WebSocketStatus>