public void run() {
        try {
            s = new ServerSocket(GAME_PORT);
            incoming = s.accept();
            inStream = incoming.getInputStream();
            outStream = incoming.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 { 
                        gameFrame.updateChatArea("\n" + opponentNickname + " says: " + line);
                    }
                }

            }
            
        } catch (IOException ex) {
            Logger.getLogger(ServerThread.class.getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showMessageDialog(null, "Server runtime error reading input or output.");
        }
    }