From cd0223e8b7387d57bbd32dacc97b8a6d4ef580d3 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Tue, 23 Oct 2018 22:41:30 -0700 Subject: [PATCH] update Connector usage --- src/ws/client/service.rs | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/ws/client/service.rs b/src/ws/client/service.rs index 8e97b743..b494564b 100644 --- a/src/ws/client/service.rs +++ b/src/ws/client/service.rs @@ -2,7 +2,7 @@ use std::marker::PhantomData; use actix_net::codec::Framed; -use actix_net::connector::{ConnectorError, DefaultConnector}; +use actix_net::connector::{Connect as TcpConnect, ConnectorError, DefaultConnector}; use actix_net::service::Service; use base64; use futures::future::{err, Either, FutureResult}; @@ -20,7 +20,7 @@ use ws::Codec; use super::{ClientError, Connect, Protocol}; /// Default client, uses default connector. -pub type DefaultClient = Client>; +pub type DefaultClient = Client; /// WebSocket's client pub struct Client @@ -33,7 +33,7 @@ where impl Client where - T: Service, + T: Service, T::Response: AsyncRead + AsyncWrite, { /// Create new websocket's client factory @@ -42,7 +42,7 @@ where } } -impl Default for Client> { +impl Default for Client { fn default() -> Self { Client::new(DefaultConnector::default()) } @@ -50,7 +50,7 @@ impl Default for Client> { impl Clone for Client where - T: Service + Clone, + T: Service + Clone, T::Response: AsyncRead + AsyncWrite, { fn clone(&self) -> Self { @@ -62,7 +62,7 @@ where impl Service for Client where - T: Service, + T: Service, T::Response: AsyncRead + AsyncWrite + 'static, T::Future: 'static, { @@ -129,18 +129,14 @@ where ); // prep connection - let host = { - let uri = request.uri(); - format!( - "{}:{}", - uri.host().unwrap(), - uri.port().unwrap_or_else(|| proto.port()) - ) - }; + let connect = TcpConnect::new( + request.uri().host().unwrap(), + request.uri().port().unwrap_or_else(|| proto.port()), + ); let fut = Box::new( self.connector - .call(host) + .call(connect) .map_err(|e| ClientError::from(e)) .and_then(move |io| { // h1 protocol