<?php
/*----------------------------------------------------------------------------------|  www.vdm.io  |----/
				fdsh 
/-------------------------------------------------------------------------------------------------------/

	@version		1.0.36
	@build			28th March, 2023
	@created		17th December, 2020
	@package		Reservation
	@subpackage		sendmessage.php
	@author			farhad shahbazi <http://farhad.com>	
	@copyright		Copyright (C) 2015. All Rights Reserved
	@license		GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
  ____  _____  _____  __  __  __      __       ___  _____  __  __  ____  _____  _  _  ____  _  _  ____ 
 (_  _)(  _  )(  _  )(  \/  )(  )    /__\     / __)(  _  )(  \/  )(  _ \(  _  )( \( )( ___)( \( )(_  _)
.-_)(   )(_)(  )(_)(  )    (  )(__  /(__)\   ( (__  )(_)(  )    (  )___/ )(_)(  )  (  )__)  )  (   )(  
\____) (_____)(_____)(_/\/\_)(____)(__)(__)   \___)(_____)(_/\/\_)(__)  (_____)(_)\_)(____)(_)\_) (__) 

/------------------------------------------------------------------------------------------------------*/

// No direct access to this file
defined('_JEXEC') or die('Restricted access');


/***[JCBGUI.joomla_plugin.head.63.$$$$]***/
define('DS', DIRECTORY_SEPARATOR);
jimport( 'joomla.plugin.plugin' );

JLoader::registerNamespace('vendor', JPATH_PLUGINS.DS.'chat'.DS.'sendMessage'.DS. 'pusher');
use vendor\pusher\pusherphpserver\src\Pusher;/***[/JCBGUI$$$$]***/


class PlgChatSendMessage extends JEvent
{

/***[JCBGUI.joomla_plugin.main_class_code.63.$$$$]***/
  public function afterChatSave($data)
  {
    $filename = __DIR__ . '/log.txt';
    file_put_contents($filename, 'data = ' . print_r($data, True) . "\n", FILE_APPEND);
    $app_id= '1119039';
    $app_key= 'ded62ba8f60c31da4778';
    $app_secret= '66ee3778f9e908cb46ae';
    $app_cluster= 'ap2';

    $channel_token= $data['channel_token'];
    unset($data['channel_token']);
    file_put_contents($filename, 'data2 = ' . print_r($data, True) . "\n", FILE_APPEND);
    file_put_contents($filename, 'channel_token = ' . print_r($channel_token, True) . "\n", FILE_APPEND);
    $pusher = new Pusher($app_key,$app_secret,$app_id,array('cluster'=>$app_cluster));
    $ss = $pusher->trigger($channel_token,'my-event', $data);
    file_put_contents($filename, 'ss = ' . print_r($data, True) . "\n", FILE_APPEND);
    return true;

  }/***[/JCBGUI$$$$]***/

}
