"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Handler_OutboundStreamOnClose = void 0;
const ffi_napi_1 = require("ffi-napi");
const gc_pin_1 = require("../gc-pin");
const native_1 = require("../native");
const rainway_ffi_1 = require("../rainway-ffi");
/** @internal */
class Handler_OutboundStreamOnClose {
    /** @internal */
    constructor(onChanged) {
        this.onChanged = onChanged;
        this.pinned = new gc_pin_1.GCPin(this);
        this.callbackUserData = new rainway_ffi_1.RainwayUserDataDef({
            data: native_1.NULL_POINTER,
            drop: () => {
                // unpin ourselves on drop
                this.pinned.release();
            },
        });
        this.callback = new ffi_napi_1.Callback("int32", ["void *", rainway_ffi_1.RainwayVoidDef], (_, __) => {
            this.onChanged();
            return native_1.VOID;
        });
        this.handler = new rainway_ffi_1.RainwayStreamCloseHandlerDef({
            userData: this.callbackUserData,
            handler: this.callback,
        });
    }
}
exports.Handler_OutboundStreamOnClose = Handler_OutboundStreamOnClose;
//# sourceMappingURL=Handler_OutboundStreamOnClose.js.map