public void read() throws IOException {
		//we need to get the current key about our channel
		//The key returned when this channel was last registered with the given selector, or null if this channel is not 
		//currently registered with that selector 
		SelectionKey key = this.channel.keyFor(this.nioEngineImp.getSelector());
		lengthBufferRead.clear();
		int nb;
		
		if(currentStateRead == READING_DONE){
			bufferRead = null;
			lengthBufferRead.position(0);
			currentStateRead = READING_LENGTH;
		}
		
		if(currentStateRead == READING_LENGTH){	
			try{
				nb = channel.read(lengthBufferRead);		
			}catch(IOException e){
				key.channel().close();
				key.cancel();
				return;
			}

			// -1 case : we close the connection
			if(nb == -1){
				key.channel().close();
				key.cancel();
				NioEngine.panic("nb = -1 : error during reading length");
				return;
			}


			if(lengthBufferRead.remaining() == 0){
				lengthBufferRead.position(0);
				int length = lengthBufferRead.getInt(0);
				bufferRead = ByteBuffer.allocate(length);
				currentStateRead = READING_MSG;
			}

		} if(currentStateRead == READING_MSG){	

			try{

				nb = channel.read(bufferRead);
			}catch(IOException e){
				key.channel().close();
				key.cancel();
				NioEngine.panic("nb = -1 : error during reading message");
				return;
			}

			// cas avec -1 fermeture de connection
			if(nb == -1){
				key.channel().close();
				key.cancel();
				return;
			}

			//we read all the buffer so we send
			if(bufferRead.remaining() == 0){
				//we duplicate because the buffer will be remplace by a new buffer
				// on the next step, so mb we will lost our message
				callback.deliver(this, bufferRead.duplicate());
				currentStateRead = READING_DONE;
			}
		}

	}