<?php
/**
 * @package messenger
 * @author kputyr
 *
 * This script runs when a client disconnects from a subscription.
 */
namespace IMATHUZH\Qfq\Core\Messenger\Hooks;

require_once(__DIR__ . '/request.php');

$request = new NchanRequest();

// Notify controller about unsubscription
$request->notifyController([
    MESSENGER_KEY_TYPE => MESSENGER_TYPE_MESSAGE,
    MESSENGER_KEY_NAME => MESSENGER_EVENT_UNSUBSCRIBE,
    MESSENGER_KEY_PAYLOAD => [
        MESSENGER_KEY_CHANNEL => $request->getChannel(),
        MESSENGER_KEY_GROUP => $request->getGroup(),
        MESSENGER_KEY_TIMESTAMP => time()
    ]
]);
