<filename>generated/java/com/github/helloiampau/janus/generated/ProtocolDelegate.java
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from janus-client.djinni

package com.github.helloiampau.janus.generated;

import android.util.Log;

import java.util.concurrent.atomic.AtomicBoolean;

public abstract class ProtocolDelegate {
    private static String TAG = "pd java_native_janus_log";
    public abstract void onReady();

    public abstract void onClose();

    public abstract void onError(JanusError error, Bundle context);

    public abstract void onEvent(JanusEvent event, Bundle context);

    public abstract void onHangup(String reason);

    private static final class CppProxy extends ProtocolDelegate
    {
        private final long nativeRef;
        private final AtomicBoolean destroyed = new AtomicBoolean(false);

        private CppProxy(long nativeRef)
        {
            Log.d(TAG, "CppProxy");
            if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
            this.nativeRef = nativeRef;
        }

        private native void nativeDestroy(long nativeRef);
        public void _djinni_private_destroy()
        {
            Log.d(TAG, "_djinni_private_destroy");
            boolean destroyed = this.destroyed.getAndSet(true);
            if (!destroyed) nativeDestroy(this.nativeRef);
        }
        protected void finalize() throws java.lang.Throwable
        {
            Log.d(TAG, "finalize");
            _djinni_private_destroy();
            super.finalize();
        }

        @Override
        public void onReady()
        {
            Log.d(TAG, "onReady");
            assert !this.destroyed.get() : "trying to use a destroyed object";
            native_onReady(this.nativeRef);
        }
        private native void native_onReady(long _nativeRef);

        @Override
        public void onClose()
        {
            Log.d(TAG, "onClose");
            assert !this.destroyed.get() : "trying to use a destroyed object";
            native_onClose(this.nativeRef);
        }
        private native void native_onClose(long _nativeRef);

        @Override
        public void onError(JanusError error, Bundle context)
        {
            Log.d(TAG, "onError");
            assert !this.destroyed.get() : "trying to use a destroyed object";
            native_onError(this.nativeRef, error, context);
        }
        private native void native_onError(long _nativeRef, JanusError error, Bundle context);

        @Override
        public void onEvent(JanusEvent event, Bundle context)
        {
            Log.d(TAG, "onEvent");
            assert !this.destroyed.get() : "trying to use a destroyed object";
            native_onEvent(this.nativeRef, event, context);
        }
        private native void native_onEvent(long _nativeRef, JanusEvent event, Bundle context);

        @Override
        public void onHangup(String reason)
        {
            Log.d(TAG, "onHangup");
            assert !this.destroyed.get() : "trying to use a destroyed object";
            native_onHangup(this.nativeRef, reason);
        }
        private native void native_onHangup(long _nativeRef, String reason);
    }
}
