private synchronized void takeAction(MessageObj mess, InetAddress address, ObjectOutputStream out) {

        switch (mess.getMsgType()) {
            //User asked for list of users
            case 0:
                returnUsers(out);
                break;
            //User sent a message
            case 1:
                sendMessage(mess);
                break;
            //User logged out
            case 2:
                removeUser(address);
                break;
            //User changed username
            case 3:
                setUsername(mess, address);
                break;
            //User logged in
            case 4:
                setUsername(mess, address);
                sendLoginMessage(mess);
                break;
        }
    }