Fix CommonTransport not accepting TCP/IP (#229)

This commit is contained in:
Pierre Krieger
2018-05-31 17:16:23 +02:00
committed by GitHub
parent 4c2cabca93
commit f193a2eb0c

View File

@ -59,15 +59,14 @@ pub struct CommonTransport {
inner: CommonTransportInner inner: CommonTransportInner
} }
#[derive(Debug, Clone)]
#[cfg(not(target_os = "emscripten"))] #[cfg(not(target_os = "emscripten"))]
struct CommonTransportInner { pub type InnerImplementation = core::transport::OrTransport<dns::DnsConfig<tcp::TcpConfig>, websocket::WsConfig<dns::DnsConfig<tcp::TcpConfig>>>;
inner: websocket::WsConfig<dns::DnsConfig<tcp::TcpConfig>>,
}
#[derive(Debug, Clone)]
#[cfg(target_os = "emscripten")] #[cfg(target_os = "emscripten")]
pub type InnerImplementation = websocket::BrowserWsConfig;
#[derive(Debug, Clone)]
struct CommonTransportInner { struct CommonTransportInner {
inner: websocket::BrowserWsConfig, inner: InnerImplementation,
} }
impl CommonTransport { impl CommonTransport {
@ -77,10 +76,11 @@ impl CommonTransport {
pub fn new(tokio_handle: tokio_core::reactor::Handle) -> CommonTransport { pub fn new(tokio_handle: tokio_core::reactor::Handle) -> CommonTransport {
let tcp = tcp::TcpConfig::new(tokio_handle); let tcp = tcp::TcpConfig::new(tokio_handle);
let with_dns = dns::DnsConfig::new(tcp); let with_dns = dns::DnsConfig::new(tcp);
let with_ws = websocket::WsConfig::new(with_dns); let with_ws = websocket::WsConfig::new(with_dns.clone());
let inner = with_dns.or_transport(with_ws);
CommonTransport { CommonTransport {
inner: CommonTransportInner { inner: with_ws } inner: CommonTransportInner { inner }
} }
} }
@ -95,11 +95,6 @@ impl CommonTransport {
} }
} }
#[cfg(not(target_os = "emscripten"))]
pub type InnerImplementation = websocket::WsConfig<dns::DnsConfig<tcp::TcpConfig>>;
#[cfg(target_os = "emscripten")]
pub type InnerImplementation = websocket::BrowserWsConfig;
impl Transport for CommonTransport { impl Transport for CommonTransport {
type Output = <InnerImplementation as Transport>::Output; type Output = <InnerImplementation as Transport>::Output;
type Listener = <InnerImplementation as Transport>::Listener; type Listener = <InnerImplementation as Transport>::Listener;