Now i created a Client for the HOPP. i made a button which submits the guess to the server, but logically this doesnt output. What do you think seems to be the problem here.

public void actionPerformed(ActionEvent e){
        String command = e.getActionCommand();
        if(command.equals("Join Game")){
            serverResponseArea.append("Sending join game request\n");
            try{
                clientHOPP.send(new Message(JOIN_REQUEST));
                Message msg = (Message)clientHOPP.receive();
                if(msg.getType() == JOIN_ACK){    
                    serverResponseArea.append("Successfully joined game\n");
                    activeGame = true;
                    joinButton.setEnabled(false);
                }
            } catch (IOException e1) {
                serverResponseArea.append("Communication Error: "+e1.getMessage());
            } catch (ClassNotFoundException cnf) {
                serverResponseArea.append(cnf.getMessage());
            }
        }
        else if(command.equals("Submit Guess")){
            String inString = guessField.getText().trim();
            if(inString == null || inString.length() == 0){
                serverResponseArea.append("Please enter a number \n");
            }
            int input = Integer.parseInt(inString);
            serverResponseArea.append("Guess is: " + inString +"\n");
            try{
                clientHOPP.send(new Message(input));
                /*Test*/serverResponseArea.append(input+" sent.\n");
                guessField.setText("");
                Message inMsg = (Message)clientHOPP.receive();
                if(inMsg.getType()== GUESS_RESPONSE)
                {    
                    GuessResponse response = (GuessResponse)inMsg.getMessageContents();
                    if(response.getResponseType()==HIGHER)
                        serverResponseArea.append("(Guess # "+response.getGuessNumber()+"): HIGHER!");
                    else if(response.getResponseType() == LOWER)
                        serverResponseArea.append("(Guess # "+response.getGuessNumber()+"): LOWER!");
                    else if(response.getResponseType() == INVALID_NUMBER)
                        serverResponseArea.append("Invalid number. Please choose a number between 1 - 999");
                    else if(response.getResponseType() == WIN)
                        serverResponseArea.append("Congratulations. You Win in "+response.getGuessNumber()+" guesses");
                    else if(response.getResponseType() == LOSE)
                        serverResponseArea.append("Sorry, you lose");
                }
            } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            } catch(ClassNotFoundException cnf){
                serverResponseArea.append(cnf.getMessage());
            }
            serverResponseArea.append(inString+"\n");
            guessField.setText("");
        } 
    }
}

This will not be very easy to debug with just the code you posted, as there are several interacting classes here. If you do not have an IDE that will let you step through the code as it executes, then you will need to place assertions or System.out.println() statements at the various stages to verify what is being received and processed on the client and server side. I would recommend starting with testing what response the client is receiving. If that result is not correct then check how the server is processing the input. Good luck!

If you are getting specific exceptions or odd behavior you don't understand, post them back here and perhaps we can help.

Yeah i did some debugging. I was getting a null because my streams werent initialised in the right order. Thanks for the tip
I love the support on this forum.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.