All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.frostwire.jlibtorrent.alerts.DhtErrorAlert Maven / Gradle / Ivy

There is a newer version: 1.2.0.18
Show newest version
package com.frostwire.jlibtorrent.alerts;

import com.frostwire.jlibtorrent.ErrorCode;
import com.frostwire.jlibtorrent.swig.dht_error_alert;

/**
 * Posted when something fails in the DHT. This is not necessarily a fatal
 * error, but it could prevent proper operation.
 *
 * @author gubatron
 * @author aldenml
 */
public final class DhtErrorAlert extends AbstractAlert {

    DhtErrorAlert(dht_error_alert alert) {
        super(alert);
    }

    /**
     * The error code.
     *
     * @return
     */
    public ErrorCode error() {
        return new ErrorCode(alert.getError());
    }

    /**
     * the operation that failed
     *
     * @return
     */
    public Operation operation() {
        return Operation.fromSwig(alert.getOperation());
    }

    public enum Operation {

        UNKNOWN(dht_error_alert.op_t.unknown),

        HOSTNAME_LOOKUP(dht_error_alert.op_t.hostname_lookup);

        private Operation(dht_error_alert.op_t swigObj) {
            this.swigObj = swigObj;
        }

        private final dht_error_alert.op_t swigObj;

        public dht_error_alert.op_t getSwig() {
            return swigObj;
        }

        public static Operation fromSwig(dht_error_alert.op_t swigObj) {
            Operation[] enumValues = Operation.class.getEnumConstants();
            for (Operation ev : enumValues) {
                if (ev.getSwig() == swigObj) {
                    return ev;
                }
            }
            throw new IllegalArgumentException("No enum " + Operation.class + " with swig value " + swigObj);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy