package dev.quicproquo;

/**
 * JNI bridge to libquicproquo_ffi native library.
 *
 * <p>Load the library with:
 * <pre>{@code
 * System.loadLibrary("quicproquo_ffi");
 * }</pre>
 */
final class NativeBridge {
    static final int QPQ_OK = 0;
    static final int QPQ_ERROR = 1;
    static final int QPQ_AUTH_FAILED = 2;
    static final int QPQ_TIMEOUT = 3;
    static final int QPQ_NOT_CONNECTED = 4;

    static {
        System.loadLibrary("quicproquo_ffi");
    }

    static native long nativeConnect(String server, String caCert, String serverName);
    static native int nativeLogin(long handle, String username, String password);
    static native int nativeSend(long handle, String recipient, byte[] message);
    static native String nativeReceive(long handle, int timeoutMs);
    static native void nativeDisconnect(long handle);
    static native String nativeLastError(long handle);

    private NativeBridge() {}
}
