fn dispatch_read<T>(&mut self, token: Token, ctx: &Context<T>) -> io::Result<()>
        where T : serialize::MessageHandler + Sized {
        let mut conns = ctx._conns.write().unwrap();
        let client_op = conns.get_mut(token);
        let client = match client_op {
            Some(expr) => expr,
            None => {
                println!("no client got:{:?}", token);
                return Err(Error::new(ErrorKind::InvalidData, "invlid token"));
            }
        };

        loop {
            let read_result = client.on_read();
            if let Ok(read_op) = read_result {
                if let Some(message) = read_op {
                    let rc_message = Arc::new(message);
                    println!("client send message start..");
                    // Queue up a write for all connected clients.
                    let handler = ctx._handle.read().unwrap();
                    handler.on_message_received(&client, &rc_message)?
                    //client.send_message(rc_message.clone());
                } else {
                    println!("forward read: no message got");
                    break;
                }
            } else {
                println!("forward read: read failed");
                return Err(Error::new(ErrorKind::InvalidData, "read failed"));
            }
        }
        Ok(())
    }
//dispatcher all of the read events to registered handler
dispatcher all of the read events to registered handler
dispatcher all of the read events to registered handler
fn dispatch_read<T>(&mut self, token: Token, ctx: &Context<T>) -> io::Result<()>
        where T : serialize::MessageHandler + Sized {
        let mut conns = ctx._conns.write().unwrap();
        let client_op = conns.get_mut(token);
        let client = match client_op {
            Some(expr) => expr,
            None => {
                println!("no client got:{:?}", token);
                return Err(Error::new(ErrorKind::InvalidData, "invlid token"));
            }
        };
        loop {
            let read_result = client.on_read();
            if let Ok(read_op) = read_result {
                if let Some(message) = read_op {
                    let rc_message = Arc::new(message);
                    println!("client send message start..");
                    // Queue up a write for all connected clients.
                    let handler = ctx._handle.read().unwrap();
                    handler.on_message_received(&client, &rc_message)?
                    //client.send_message(rc_message.clone());
                } else {
                    println!("forward read: no message got");
                    break;
                }
            } else {
                println!("forward read: read failed");
                return Err(Error::new(ErrorKind::InvalidData, "read failed"));
            }
        }
        Ok(())
    }
fn dispatch_read < T > ( & mut self , token : Token , ctx : & Context < T > ) -> io :: Result < ( ) > where T : serialize :: MessageHandler + Sized { let mut conns = ctx . _conns . write ( ) . unwrap ( ) ; let client_op = conns . get_mut ( token ) ; let client = match client_op { Some ( expr ) => expr , None => { println ! ( " " token ) ; return Err ( Error :: new ( ErrorKind :: InvalidData , " " ) ) ; } } ; loop { let read_result = client . on_read ( ) ; if let Ok ( read_op ) = read_result { if let Some ( message ) = read_op { let rc_message = Arc :: new ( message ) ; println ! ( " " ) ; // Queue up a write for all connected clients. let handler = ctx . _handle . read ( ) . unwrap ( ) ; handler . on_message_received ( & client , & rc_message ) ? //client.send_message(rc_message.clone()); } else { println ! ( " " ) ; break ; } } else { println ! ( " " ) ; return Err ( Error :: new ( ErrorKind :: InvalidData , " " ) ) ; } } Ok ( ( ) ) }
dispatcher all of the read events to registered handler
dispatcher all of the read events to registered handler
&mut self
token
Token
ctx
&Context<T>
&mut self
token
Token
ctx
&Context<T>