@SuppressWarnings("incomplete-switch")
    /* package */void processOutputMessage (BitTorrentMessage msg) {
        assert msg != null;

        switch (msg.getMessageType()) {
            case HANDSHAKE_START:
                HandShakeStart hss = (HandShakeStart) msg;
                localFlags.or(hss.getFlags());
                localHash = hss.getHash();
                localProtocol = hss.getProtocolName();
                localHandShakeStarted = true;
            break;

            case HANDSHAKE_END:
                HandShakeEnd hse = (HandShakeEnd) msg;
                localPeerId = hse.getPeerId();
                localHandShakeFinished = true;
            break;

            case CHOKE:
                localChoking = true;
            break;

            case UNCHOKE:
                localChoking = false;
            break;

            case INTERESTED:
                localInterested = true;
            break;

            case UNINTERESTED:
                localInterested = false;
            break;

            case HAVE:
                localClaimedPieces.set(((HaveMessage) msg).getPieceIndex());
            break;

            case BITFIELD:
                localClaimedPieces.or(((BitFieldMessage) msg).getBitField());
            break;
        }
    }