/// Create a new connection handler.
Create a new connection handler.
Create a new connection handler .
fn new<S: IntoSsl>(
        logger: L,
        s: S, 
        cmd_sender: Q,
        addr: &SocketAddr, 
        arrow_mac: &MacAddr,
        app_context: Shared<AppContext>, 
        event_loop: &mut EventLoop<Self>) -> Result<Self> {
        let stream = try_arr!(ArrowStream::connect(s, addr, 0, event_loop));
        let mut res = ConnectionHandler {
            logger:        logger,
            app_context:   app_context,
            cmd_sender:    cmd_sender,
            stream:        stream,
            sessions:      HashMap::new(),
            session_queue: VecDeque::new(),
            read_buffer:   Box::new([0u8; 32768]),
            write_buffer:  Box::new([0u8; 16384]),
            req_parser:    ArrowMessageParser::new(),
            output_buffer: WriteBuffer::new(256 * 1024),
            result:        None,
            state:         ProtocolState::Handshake,
            last_update:   None,
            write_tout:    Timeout::new(),
            ack_tout:      Timeout::new(),
            msg_id:        0,
            expected_acks: VecDeque::new()
        };
        res.create_register_request(arrow_mac, event_loop);
        // start timeout checker:
        event_loop.timeout_ms(
                TimerEvent::TimeoutCheck(0),
                TIMEOUT_CHECK_PERIOD)
            .unwrap();
        Ok(res)
    }
fn new < S : IntoSsl > ( logger : L , s : S , cmd_sender : Q , addr : & SocketAddr , arrow_mac : & MacAddr , app_context : Shared < AppContext > , event_loop : & mut EventLoop < Self > ) -> Result < Self > { let stream = try_arr ! ( ArrowStream connect ( s addr 0 event_loop ) ) ; let mut res = ConnectionHandler { logger : logger , app_context : app_context , cmd_sender : cmd_sender , stream : stream , sessions : HashMap :: new ( ) , session_queue : VecDeque :: new ( ) , read_buffer : Box :: new ( [ 0u8 ; 32768 ] ) , write_buffer : Box :: new ( [ 0u8 ; 16384 ] ) , req_parser : ArrowMessageParser :: new ( ) , output_buffer : WriteBuffer :: new ( 256 * 1024 ) , result : None , state : ProtocolState :: Handshake , last_update : None , write_tout : Timeout :: new ( ) , ack_tout : Timeout :: new ( ) , msg_id : 0 , expected_acks : VecDeque :: new ( ) } ; res . create_register_request ( arrow_mac , event_loop ) ; // start timeout checker: event_loop . timeout_ms ( TimerEvent :: TimeoutCheck ( 0 ) , TIMEOUT_CHECK_PERIOD ) . unwrap ( ) ; Ok ( res ) }
Create a new connection handler.
Create a new connection handler .
logger
L
s
S
cmd_sender
Q
addr
&SocketAddr
arrow_mac
&MacAddr
app_context
Shared<AppContext>
event_loop
&mut EventLoop<Self>