<?php
defined('BASEPATH') or exit('No direct script access allowed');

require_once FCPATH . 'vendor/autoload.php';

class Pusher
{
    protected $CI;
    protected $pusher;

    public function __construct()
    {
        $this->CI = &get_instance();
        $this->CI->config->load('pusher');

        $options = array(
            'cluster' => $this->CI->config->item('pusher_app_cluster'),
            'useTLS' => $this->CI->config->item('pusher_use_encryption')
        );

        $this->pusher = new \Pusher\Pusher(
            $this->CI->config->item('pusher_app_key'),
            $this->CI->config->item('pusher_app_secret'),
            $this->CI->config->item('pusher_app_id'),
            $options
        );
    }

    public function trigger($channel, $event, $data)
    {
        $this->pusher->trigger($channel, $event, $data);
    }
}
