public void run() {
        try {
            s = new Socket(ip, ServerThread.GAME_PORT);
            inStream = s.getInputStream();
            outStream = s.getOutputStream();
            in = new BufferedReader(new InputStreamReader(inStream));
            out = new PrintWriter(outStream,true);
            
            sendInitialValues();            

            while(true) {

                //if user has made a move
                if(game.isSendMove())
                    sendMove();

                //if wants to send chat message
                if(game.isSendMsg())
                    sendMessage();

                //read input
                if(in.ready()) {
                    line = in.readLine();

                    //if input is a move
                    if( !line.equals("") && line.charAt(0) == '#')
                        updateBoard();

                    //if input is a chat message
                    else
                        updateChatArea();
                }
            }
            
        } catch (UnknownHostException ex) {
            Logger.getLogger(ClientThread.class.getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showMessageDialog(null, "Could not locate host.");
        } catch (IOException ex) {
            Logger.getLogger(ClientThread.class.getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showMessageDialog(null, "Client error.");
        }
    }