public void run() {
        
		
        try {
        
			BufferedInputStream bis = new BufferedInputStream(connection.getInputStream());
            while (true) {
        
                ClientCommandInterface cci = null;
				
				if (bis.available() > 0) {
					cci = (ClientCommandInterface) ois.readObject();
				}
				else if (!commandsQueue.isEmpty()) {
					cci = (ClientCommandInterface) commandsQueue.remove();
				}
				
				if (cci != null) {
					cci.process(this);
				}
            }
        }
		catch (EOFException e) {
		
			// Lost connection while trying to read from the stream.
			System.out.println( "Server connection lost.." );
			System.out.println( "Thread exiting." );
			return;
		}
		
		catch (Exception e) {
				
			// Encountered an exception. Probably I should close the connection and
			// remove the client.
			System.out.println( "Encountered exception" + e.getMessage());
			e.printStackTrace();
			return;
		}
    }