pub fn run(listen_addr: SocketAddr, secret_key: String, mgr_sender: MgrSender) {
    let tb = thread::Builder::new().name("ctl-gateway".to_string());
    tb.spawn(move || {
          let mut core = reactor::Core::new().unwrap();
          let handle = core.handle();
          let state = SrvState { secret_key,
                                 mgr_sender };
          let state = Rc::new(RefCell::new(state));
          let server =
              TcpListener::bind(&listen_addr).expect("Could not bind ctl gateway listen address!")
                                             .incoming()
                                             .map(|tcp_stream| {
                                                 let addr =
                                                     tcp_stream.peer_addr().expect("Couldn't get \
                                                                                    peer address!");
                                                 let io = SrvCodec::new().framed(tcp_stream);
                                                 let client = Client { handle: handle.clone(),
                                                                       state:  state.clone(), };
                                                 (client.serve(io), addr)
                                             })
                                             .for_each(|(client, addr)| {
                                                 handle.spawn(client.then(move |res| {
                                                                        debug!("DISCONNECTED \
                                                                                from {:?} with \
                                                                                result {:?}",
                                                                               addr, res);
                                                                        future::ok(())
                                                                    }));
                                                 Ok(())
                                             });
          core.run(server)
      })
      .expect("ctl-gateway thread start failure");
}
/// Start a new thread which will run the CtlGateway server.
///
/// New connections will be authenticated using `secret_key`. Messages from the main thread
/// will be sent over the channel `mgr_sender`.
Start a new thread which will run the CtlGateway server.
New connections will be authenticated using `secret_key`. Messages from the main thread
will be sent over the channel `mgr_sender`.
Start a new thread which will run the CtlGateway server . New connections will be authenticated using ` secret_key ` . Messages from the main thread will be sent over the channel ` mgr_sender ` .
pub fn run(listen_addr: SocketAddr, secret_key: String, mgr_sender: MgrSender) {
    let tb = thread::Builder::new().name("ctl-gateway".to_string());
    tb.spawn(move || {
          let mut core = reactor::Core::new().unwrap();
          let handle = core.handle();
          let state = SrvState { secret_key,
                                 mgr_sender };
          let state = Rc::new(RefCell::new(state));
          let server =
              TcpListener::bind(&listen_addr).expect("Could not bind ctl gateway listen address!")
                                             .incoming()
                                             .map(|tcp_stream| {
                                                 let addr =
                                                     tcp_stream.peer_addr().expect("Couldn't get \
                                                                                    peer address!");
                                                 let io = SrvCodec::new().framed(tcp_stream);
                                                 let client = Client { handle: handle.clone(),
                                                                       state:  state.clone(), };
                                                 (client.serve(io), addr)
                                             })
                                             .for_each(|(client, addr)| {
                                                 handle.spawn(client.then(move |res| {
                                                                        debug!("DISCONNECTED \
                                                                                from {:?} with \
                                                                                result {:?}",
                                                                               addr, res);
                                                                        future::ok(())
                                                                    }));
                                                 Ok(())
                                             });
          core.run(server)
      })
      .expect("ctl-gateway thread start failure");
}
pub fn run ( listen_addr : SocketAddr , secret_key : String , mgr_sender : MgrSender ) { let tb = thread :: Builder :: new ( ) . name ( " " . to_string ( ) ) ; tb . spawn ( move | | { let mut core = reactor :: Core :: new ( ) . unwrap ( ) ; let handle = core . handle ( ) ; let state = SrvState { secret_key , mgr_sender } ; let state = Rc :: new ( RefCell :: new ( state ) ) ; let server = TcpListener :: bind ( & listen_addr ) . expect ( " " ) . incoming ( ) . map ( | tcp_stream | { let addr = tcp_stream . peer_addr ( ) . expect ( " \
 " ) ; let io = SrvCodec :: new ( ) . framed ( tcp_stream ) ; let client = Client { handle : handle . clone ( ) , state : state . clone ( ) , } ; ( client . serve ( io ) , addr ) } ) . for_each ( | ( client , addr ) | { handle . spawn ( client . then ( move | res | { debug ! ( " \
 \
 " addr res ) ; future :: ok ( ( ) ) } ) ) ; Ok ( ( ) ) } ) ; core . run ( server ) } ) . expect ( " " ) ; }
Start a new thread which will run the CtlGateway server.
Start a new thread which will run the CtlGateway server .
listen_addr
SocketAddr
secret_key
String
mgr_sender
MgrSender
listen_addr
SocketAddr
secret_key
String
mgr_sender
MgrSender