public function handshakeInput($buffer, $connection) 
    {
        $len = parent::input($buffer, $connection);
        
        if(!$len)  return 0;
        
        $req = new HttpReqeust();
        $req->loadRequest($buffer);
        
        if($req->headers->get('Connection') !== 'Upgrade'){
            throw new \Exception("Bad Connection", 412);
        }
        
        if($req->headers->get('Upgrade') !== 'websocket'){
            throw new \Exception("Bad Upgrade", 412);
        }
        
        $seckey = $req->headers->get('Sec-Websocket-Key');
        if(!$seckey ||  base64_encode(base64_decode($seckey)) !== $seckey){
            throw new \Exception("Bad Websocket-Key", 412);
        }
        
        return $len;
    }