public function handleConnection($socket)
    {
        stream_set_blocking($socket, 0);
        $client = $this->createConnection($socket);

        $timer = $this->loop->addTimer(5, function() use ($client) {
            $client->removeAllListeners('init');
            $client->end('Timeout waiting for PROXY header.');
            $this->emit('proxytimeout', [new Connection($client->stream, $this->loop)]);
        });

        $client->on('init', function($connection) use ($client, $timer) {
            $timer->cancel();
            $this->emit('connection', [$connection]);
        });
    }
public function handleConnection($socket)
    {
        stream_set_blocking($socket, 0);
        $client = $this->createConnection($socket);

        $timer = $this->loop->addTimer(5, function() use ($client) {
            $client->removeAllListeners('init');
            $client->end('Timeout waiting for PROXY header.');
            $this->emit('proxytimeout', [new Connection($client->stream, $this->loop)]);
        });

        $client->on('init', function($connection) use ($client, $timer) {
            $timer->cancel();
            $this->emit('connection', [$connection]);
        });
    }
public function handleConnection ( $ socket ) { stream_set_blocking ( $ socket , 0 ) ; $ client = $ this -> createConnection ( $ socket ) ; $ timer = $ this -> loop -> addTimer ( 5 , function ( ) use ( $ client ) { $ client -> removeAllListeners ( 'init' ) ; $ client -> end ( 'Timeout waiting for PROXY header.' ) ; $ this -> emit ( 'proxytimeout' , [ new Connection ( $ client -> stream , $ this -> loop ) ] ) ; } ) ; $ client -> on ( 'init' , function ( $ connection ) use ( $ client , $ timer ) { $ timer -> cancel ( ) ; $ this -> emit ( 'connection' , [ $ connection ] ) ; } ) ; }
Handle the connection. We only emit the connection event after the proper header was received.
@param $socket
Handle the connection . We only emit the connection event after the proper header was received .