public void run() {
        
       
        try {
            DataPacket recvData;
            ResponsePacket sendData= new ResponsePacket();
            while (running) {
                System.out.println("waiting for receiving");
                
                recvData = (DataPacket) in.readObject();
                
                System.out.println("received");
                
                if (recvData.isStartGame()) {
                    System.out.println("new");
                    sendData=startNewGame();
                }
                else if (recvData.isSuggestLetterMode()) {
                    sendData=checkLetter(recvData.getLetter());
                }
                else if (recvData.isGuessWordMode()) {
                    sendData=checkWord(recvData.getWord());
                }
                out.writeObject(sendData);
                System.out.println("sent");
                
                if (out != null) {
                    out.flush();
                }
                else {
                    System.out.println("Output is null, no msg sent");
                }
            }
            try {
                out.close();
                in.close();
                socket.close();
            } catch (IOException e) {
                System.out.println("Error while closing the connection");
                e.printStackTrace();
            }
        } catch (IOException e) {
            System.out.println(e.toString());
            return;
        } catch (ClassNotFoundException e) {
            System.out.println(e.toString());
        }
    }