Ejemplo n.º 1
1
 public function deleted($clientId, $entity, $pkArray)
 {
     $channels = $this->dbClass->removeFromRegisterd($clientId, $entity, $pkArray);
     $this->loadPusher();
     $pusher = new Pusher($this->dbSettings->pusherKey, $this->dbSettings->pusherSecret, $this->dbSettings->pusherAppId);
     $data = array('entity' => $entity, 'pkvalue' => $pkArray);
     $response = $pusher->trigger($channels, 'delete', $data);
 }
Ejemplo n.º 2
1
 public function deleteGame(Event\Game\DeleteEvent $event)
 {
     $this->pusher->trigger('scangammon', Events::GAME_DELETED, $this->serializer->serialize($event->getGame(), 'json'));
     $this->pusher->trigger('scangammon', Events::STATS_UPDATED, $this->serializer->serialize($this->stats->getAll(), 'json'));
 }
Ejemplo n.º 3
0
 /**
  * Test that a user can subscribe to a pusher channel
  *
  * @return void
  */
 public function testCanSubscribeMemberToPusherChannel()
 {
     $this->request->shouldReceive('input')->times(3)->andReturn('foo');
     $this->pusher->shouldReceive('presence_auth')->once()->with('foo', 'foo', m::type('string'), ['username' => 'foo']);
     $this->call('POST', 'pusher/auth');
     $this->assertResponseOk();
 }
Ejemplo n.º 4
0
 /**
  *
  * @param $message
  * @param $channel
  * @return bool|string
  * @author Christophe Nick
  */
 public function sendMessage($message, $channel = "babel95")
 {
     date_default_timezone_set('UTC');
     $pusher = new \Pusher($this->appKey, $this->appSecret, $this->appID);
     $response = $pusher->trigger($channel, 'chat_message', $message['data'], null, true);
     return $response;
 }
 public function testSchemeIsStrippedAndIgnoredFromHostInOptions()
 {
     $options = array('host' => 'https://test.com');
     $pusher = new Pusher('app_key', 'app_secret', 'app_id', $options);
     $settings = $pusher->getSettings();
     $this->assertEquals('http', $settings['scheme']);
     $this->assertEquals('test.com', $settings['host']);
 }
Ejemplo n.º 6
0
 public function newNotification()
 {
     $post = $this->input->post();
     $channel = $post['action'];
     $message = $post['msg'];
     $type = $post['type'];
     $pusher = new Pusher($key, $secret, $app_id, $debug, $host, $port, $timeout);
     $pusher->trigger($channel, $type, array('message' => $message));
 }
Ejemplo n.º 7
0
 /**
  * Broadcast the given event.
  *
  * @param  array  $channels
  * @param  string  $event
  * @param  array  $payload
  * @return void
  */
 public function broadcast(array $channels, $event, array $payload = [])
 {
     $socket = Arr::pull($payload, 'socket');
     $response = $this->pusher->trigger($this->formatChannels($channels), $event, $payload, $socket);
     if (is_array($response) && $response['status'] >= 200 && $response['status'] <= 299 || $response === true) {
         return;
     }
     throw new BroadcastException(is_bool($response) ? 'Failed to connect to Pusher.' : $response['body']);
 }
Ejemplo n.º 8
0
 public function it_dump_composer_json_content_to_file(ConsumerEvent $event, Message $message, \Pusher $pusher, Filesystem $filesystem)
 {
     $event->getMessage()->shouldBeCalled()->willReturn($message);
     $message->getValue('channelName')->shouldBeCalled()->willReturn('new_channel');
     $message->getValue('body')->shouldBeCalled()->willReturn('composer.json content');
     $pusher->trigger('new_channel', 'consumer:new-step', array('message' => 'Starting async job'))->shouldBeCalled();
     $filesystem->mkdir(sys_get_temp_dir() . '/' . 'composer_dir')->shouldBeCalled();
     $filesystem->dumpFile(sys_get_temp_dir() . '/composer_dir/composer.json', 'composer.json content')->shouldBeCalled();
     $this->execute($event, 'composer_dir')->shouldReturn(0);
 }
 public function testEncryptedPush()
 {
     $options = array('encrypted' => true, 'host' => PUSHERAPP_HOST);
     $pusher = new Pusher(PUSHERAPP_AUTHKEY, PUSHERAPP_SECRET, PUSHERAPP_APPID, $options);
     $pusher->set_logger(new TestLogger());
     $batch = array();
     $batch[] = array('channel' => 'test_channel', 'name' => 'my_event', 'data' => array('my' => 'data'));
     $string_trigger = $this->pusher->triggerBatch($batch);
     $this->assertTrue($string_trigger, 'Trigger with string payload');
 }
Ejemplo n.º 10
0
 public function ready()
 {
     $data['aula'] = $this->input->get('aula');
     $data['piso'] = $this->input->get('piso');
     $app_id = '163670';
     $app_key = '6abac2ed749f4430d6f6';
     $app_secret = '86ce372daf8832b6df67';
     $pusher = new Pusher($app_key, $app_secret, $app_id);
     $data['message'] = 'El inconveniente ha sido solucionado en el AULA : ' . $data['aula'] . " PISO : " . $data['piso'];
     $pusher->trigger('rtc1', 'ok', $data);
 }
Ejemplo n.º 11
0
function push($secure, $article)
{
    $pusher = new Pusher($secure['pusher_key'], $secure['pusher_secret'], $secure['pusher_id'], array('encrypted' => true));
    $push = [];
    $push['pub_time'] = $article->pub_time;
    $push['title'] = $article->title;
    $push['content'] = $article->content;
    $push['link'] = $article->link;
    $push['author'] = $article->author;
    return $pusher->trigger('notablenews', 'newnews', $push);
}
 function it_push_error_message_and_alerts_when_vulnerability_found(SecurityChecker $securityChecker, ConsumerEvent $event, Message $message, \Pusher $pusher)
 {
     $event->getMessage()->shouldBeCalled()->willReturn($message);
     $message->getValue('channelName')->shouldBeCalled()->willReturn('new_channel');
     $pusher->trigger('new_channel', 'consumer:new-step', array('message' => 'Checking vulnerability'))->shouldBeCalled();
     $securityChecker->check(sys_get_temp_dir() . '/composer_dir/composer.lock', 'text')->shouldBeCalled()->willReturn($this->getVulnerabilityMessage());
     $securityChecker->getLastVulnerabilityCount()->shouldBeCalled()->willReturn(1);
     $pusher->trigger('new_channel', 'consumer:step-error', array('message' => 'Vulnerability found : 1'))->shouldBeCalled();
     $pusher->trigger('new_channel', 'consumer:vulnerabilities', array('message' => $this->getVulnerabilityMessage()))->shouldBeCalled();
     $this->execute($event, 'composer_dir')->shouldReturn(0);
 }
function pushToUser($user_id, $title, $message, $type, $typedata, $con)
{
    //get api key from https://code.google.com/apis/console/
    if (checkSettings($user_id, $type, $con)) {
        $regIds = getDeviceIdByUserId($user_id, $con);
        foreach ($regIds as $i => $regId) {
            $pusher = new Pusher();
            $pusher->notify($regId, $message, $title, $type, $typedata);
            pushLog($pusher->getOutputAsArray(), $con, $title, $message, $type, $typedata, $user_id, $regId);
        }
    }
}
Ejemplo n.º 14
0
function _callback($status)
{
    $pusher = new Pusher(PUSHER_KEY, PUSHER_SECRET, PUSHER_APP_ID);
    $id_str = $status['id_str'];
    $text = $status['text'];
    //	$id = $status['user']['id'];
    $screen_name = $status['user']['screen_name'];
    $name = $status['user']['name'];
    $profile_image_url = $status['user']['profile_image_url'];
    $json = array("data" => array("id_str" => $id_str, "text" => $text, "user" => array("name" => $name, "screen_name" => $screen_name, "profile_image_url" => $profile_image_url)));
    if ($id_str != "") {
        $pusher->trigger(PUSHER_CHANNEL_NAME, PUSHER_EVENT_NAME, $json);
    }
    //	echo $status['user']['name'].':'.$status['text'] . PHP_EOL;
    return true;
}
 /**
  * Handles form submissions
  *
  * @param   $action string  The form action being performed
  * @return          void
  */
 protected function handle_form_submission($action)
 {
     if ($this->check_nonce()) {
         // Calls the method specified by the action
         $output = $this->{$this->actions[$action]}();
         if (is_array($output) && isset($output['room_id'])) {
             $room_id = $output['room_id'];
         } else {
             throw new Exception('Form submission failed.');
         }
         // Realtime stuff happens here
         $pusher = new Pusher(PUSHER_KEY, PUSHER_SECRET, PUSHER_APPID);
         $channel = 'room_' . $room_id;
         $pusher->trigger($channel, $action, $output);
         header('Location: ' . APP_URI . 'room/' . $room_id);
         exit;
     } else {
         throw new Exception('Invalid nonce.');
     }
 }
Ejemplo n.º 16
0
	function send_message($user_id,$to,$subject,$msg,$parent_id=NULL){
		if($parent_id==0)$parent_id=NULL;
		$doc = array(
			"from" => $user_id,
			"to" => $to,
			"title" => htmlentities($subject),
			"content" => $msg,
			"parent_id" => $parent_id,
		);
		$res = $this->db->insert('messages', $doc);
		//push new message
		require_once(getcwd()."/application/helpers/pusher/Pusher.php");
		$pusher = new Pusher('deb0d323940b00c093ee', '9ab20336af22c4e7fa77', '25755');
		$data = array(
			'from' => $user_id,
			'to' => $to,
			'message_id'=> $this->db->insert_id()
		);
		$pusher->trigger('message-'.$to, 'new-message', $data );
		return $res;
	}
Ejemplo n.º 17
0
 public function addTradeHistory($trade_history)
 {
     $this->seller_id = $trade_history['seller_id'];
     $this->buyer_id = $trade_history['buyer_id'];
     $this->amount = $trade_history['amount'];
     $this->price = $trade_history['price'];
     $this->market_id = $trade_history['market_id'];
     $this->type = $trade_history['type'];
     $this->fee_buy = $trade_history['fee_buy'];
     $this->fee_sell = $trade_history['fee_sell'];
     $this->save();
     if ($this->id) {
         require_once app_path() . '/libraries/Pusher.php';
         $setting = new Setting();
         $pusher_app_id = $setting->getSetting('pusher_app_id', '');
         $pusher_app_key = $setting->getSetting('pusher_app_key', '');
         $pusher_app_secret = $setting->getSetting('pusher_app_secret', '');
         if ($pusher_app_id != '' && $pusher_app_key != '' && $pusher_app_secret != '') {
             $pusher = new Pusher($pusher_app_key, $pusher_app_secret, $pusher_app_id);
             $wallet = new Wallet();
             $market = Market::where('id', $this->market_id)->first();
             $from = strtoupper($wallet->getType($market->wallet_from));
             $to = strtoupper($wallet->getType($market->wallet_to));
             $message = array('channel' => 'trade.' . $this->market_id, 'trade' => array('timestamp' => strtotime($this->created_at), 'datetime' => date("Y-m-d H:i:s T", strtotime($this->created_at)), 'marketid' => $this->market_id, 'marketname' => $from . '/' . $to, 'amount' => sprintf("%.8f", $this->amount), 'price' => sprintf("%.8f", $this->price), 'total' => sprintf("%.8f", $this->amount * $this->price), 'type' => $this->type));
             $pusher->trigger('trade.' . $this->market_id, 'message', $message);
         }
         if (!$setting->getSetting('disable_points', 0)) {
             //Cong point cho nguoi mua va nguoi da gioi thieu ho
             $points = new PointsController();
             if ($this->fee_buy > 0) {
                 $points->addPointsTrade($this->buyer_id, $this->fee_buy, $this->id, $market->wallet_to);
             }
             //Cong point cho nguoi ban va nguoi da gioi thieu ho
             if ($this->fee_sell > 0) {
                 $points->addPointsTrade($this->seller_id, $this->fee_sell, $this->id, $market->wallet_to);
             }
         }
     }
     return $this->id;
 }
 /**
  * Trigger pusher event with latest order information
  *
  * @param  \Magento\Framework\Event\Observer $observer
  * @return \Jahvi\NewOrderNotification\Observer\DisplayNotification
  */
 public function execute(Observer $observer)
 {
     if ($this->globalConfig->getValue('checkout/newordernotification/enabled')) {
         $appId = $this->globalConfig->getValue('checkout/newordernotification/app_id');
         $appKey = $this->globalConfig->getValue('checkout/newordernotification/app_key');
         $appSecret = $this->globalConfig->getValue('checkout/newordernotification/app_secret');
         $pusher = new \Pusher($appKey, $appSecret, $appId, ['encrypted' => true]);
         // Get latest order
         $orderId = $observer->getEvent()->getOrderIds()[0];
         $order = $this->orderFactory->create()->load($orderId);
         // Get last product in order data
         $product = $order->getAllVisibleItems()[0]->getProduct();
         $shippingCity = $order->getShippingAddress()->getCity();
         $productImage = $this->imageHelper->init($product, 'product_thumbnail_image');
         // Get shipping city and country
         $shippingCountryCode = $order->getShippingAddress()->getCountryId();
         $shippingCountry = $this->countryFactory->create()->loadByCode($shippingCountryCode);
         // Trigger pusher event with collected data
         $pusher->trigger('non_channel', 'new_order', ['product_name' => $product->getName(), 'product_image' => $productImage->getUrl(), 'product_url' => $product->getProductUrl(), 'shipping_city' => $shippingCity, 'shipping_country' => $shippingCountry->getName()]);
     }
     return $this;
 }
Ejemplo n.º 19
0
use React\EventLoop\Factory;
use React\EventLoop\LoopInterface;
use React\Socket\Server;
use Rxnet\Httpd\Httpd;
use Rxnet\Httpd\HttpdRequest;
use Rxnet\Httpd\HttpdResponse;
use Rxnet\Subject\EndlessSubject;
use Rxnet\Zmq\RxZmq;
use Rxnet\Zmq\SocketWrapper;
require __DIR__ . "/../../vendor/autoload.php";
$loop = Factory::create();
$zmq = new \Rxnet\Zmq\RxZmq($loop);
$server = new Server($loop);
$endlessSubject = new EndlessSubject();
$httpd = new Httpd($server, $endlessSubject);
$pusher = new Pusher($loop, $zmq, $httpd);
$pusher->handle();
$loop->run();
class Pusher
{
    protected $sock = "ipc://zmq.sock";
    /** @var LoopInterface  */
    protected $loop;
    /** @var SocketWrapper  */
    protected $pusher;
    /** @var Httpd  */
    protected $httpd;
    public function __construct(LoopInterface $loop, \Rxnet\Zmq\RxZmq $zmq, Httpd $httpd)
    {
        $this->loop = $loop;
        $this->pusher = $zmq->push();
 /**
  * @param Request $request
  * @return string
  * @throws AuthenticationException
  */
 public function pusherAuth(Request $request)
 {
     //Verify the user has permission to connect to the chosen channel
     if ($request->get('channel_name') !== 'private-' . Auth::id()) {
         throw new AuthenticationException();
     }
     $pusher = new \Pusher(config('broadcasting.connections.pusher.key'), config('broadcasting.connections.pusher.secret'), config('broadcasting.connections.pusher.app_id'));
     return $pusher->socket_auth($request->get('channel_name'), $request->get('socket_id'));
 }
Ejemplo n.º 21
-1
 public function __construct()
 {
     define('WP_USE_THEMES', false);
     include_once dirname(dirname(dirname(dirname(__FILE__)))) . '/wp-load.php';
     $this->options = get_option('wp_pusher', false);
     if ($this->options !== false && $this->options['key'] !== '' && $this->options['secret'] !== '' && $this->options['app_id'] !== '') {
         include_once 'pusher-php-server/lib/Pusher.php';
         $pusher = new Pusher($this->options['key'], $this->options['secret'], $this->options['app_id']);
         echo $pusher->socket_auth($_POST['channel_name'], $_POST['socket_id']);
     }
 }
Ejemplo n.º 22
-1
 /**
  * Broadcast the given event.
  *
  * @param  array  $channels
  * @param  string  $event
  * @param  array  $payload
  * @return void
  */
 public function broadcast(array $channels, $event, array $payload = [])
 {
     $socket = Arr::pull($payload, 'socket');
     $this->pusher->trigger($this->formatChannels($channels), $event, $payload, $socket);
 }
Ejemplo n.º 23
-1
<?php

require __DIR__ . '/vendor/autoload.php';
$app_id = '134441';
$app_key = '599cb5ed77cd5efb659a';
$app_secret = '76a57ea82e311bcbbb1f';
error_log('post ' . var_export($_SERVER, true));
$channel_name = $_POST['channel_name'];
$socket_id = $_POST['socket_id'];
error_log($app_id);
error_log($app_key);
error_log($app_secret);
error_log('channel name: ' . $channel_name);
error_log('socket id: ' . $socket_id);
$pusher = new Pusher($app_key, $app_secret, $app_id);
echo $pusher->socket_auth($channel_name, $socket_id);
Ejemplo n.º 24
-2
 public function test_fire_and_forget_triggers_without_errors()
 {
     $options = array('host' => PUSHERAPP_HOST);
     $pusher = new Pusher(PUSHERAPP_AUTHKEY, PUSHERAPP_SECRET, PUSHERAPP_APPID, $options);
     $pusher->set_logger(new TestLogger());
     $ok = $pusher->trigger('test_channel', 'my_event', array('fireandforget' => 1));
     $this->assertTrue($ok, 'Did not force true');
 }
Ejemplo n.º 25
-2
 public function testGenerateSignature()
 {
     $time = time();
     $auth_version = '1.0';
     $method = 'POST';
     $auth_key = 'thisisaauthkey';
     $auth_secret = 'thisisasecret';
     $request_path = '/channels/test_channel/events';
     $query_params = array('name' => 'an_event');
     $auth_query_string = Pusher::build_auth_query_string($auth_key, $auth_secret, $method, $request_path, $query_params, $auth_version, $time);
     $expected_to_sign = "POST\n{$request_path}\nauth_key={$auth_key}&auth_timestamp={$time}&auth_version={$auth_version}&name=an_event";
     $expected_auth_signature = hash_hmac('sha256', $expected_to_sign, $auth_secret, false);
     $expected_query_string = "auth_key={$auth_key}&auth_signature={$expected_auth_signature}&auth_timestamp={$time}&auth_version={$auth_version}&name=an_event";
     $this->assertEquals($auth_query_string, $expected_query_string, 'auth signature valid');
 }
Ejemplo n.º 26
-2
<?php

require_once 'smswall.inc.php';
require 'libs/Pusher.php';
$pusher = new Pusher(PUSHER_KEY, PUSHER_SECRET, PUSHER_APPID);
$presence_data = array('name' => 'publicwall');
$uid = uniqid();
echo $pusher->presence_auth($_POST['channel_name'], $_POST['socket_id'], $uid, $presence_data);
 public function testEncryptedPush()
 {
     $options = array('encrypted' => true, 'host' => PUSHERAPP_HOST);
     $pusher = new Pusher(PUSHERAPP_AUTHKEY, PUSHERAPP_SECRET, PUSHERAPP_APPID, $options);
     $pusher->set_logger(new TestLogger());
     $structure_trigger = $pusher->trigger('test_channel', 'my_event', array('encrypted' => 1));
     $this->assertTrue($structure_trigger, 'Trigger with over encrypted connection');
 }
Ejemplo n.º 28
-3
 public function actionSetsent()
 {
     // echo $_REQUEST[id];
     if (isset($_REQUEST['id'])) {
         $model = ProjectComment::model()->findByPk($_REQUEST['id']);
         $model->status = 1;
         if ($model->save()) {
             if ($this->sendMailProgres($model->project_views_id)) {
                 $app_id = '163881';
                 $app_key = '06626efc2ad436f73364';
                 $app_secret = 'e434d8ce60e96058f3e8';
                 $pusher = new Pusher($app_key, $app_secret, $app_id, array('encrypted' => true));
                 $data['message'] = 'hello worlds';
                 $pusher->trigger('test_channel', 'my_event', $data);
             }
         }
         // echo "succes set sent";main
         // $this->redirect(array('land/uploaded'));
         // echo "sukses";
     }
 }
Ejemplo n.º 29
-3
 /**
  * Build the required HMAC'd auth string
  *
  * @param string $auth_key
  * @param string $auth_secret
  * @param string $request_method
  * @param string $request_path
  * @param array $query_params
  * @param string $auth_version [optional]
  * @param string $auth_timestamp [optional]
  * @return string
  */
 public static function build_auth_query_string($auth_key, $auth_secret, $request_method, $request_path, $query_params = array(), $auth_version = '1.0', $auth_timestamp = null)
 {
     $params = array();
     $params['auth_key'] = $auth_key;
     $params['auth_timestamp'] = is_null($auth_timestamp) ? time() : $auth_timestamp;
     $params['auth_version'] = $auth_version;
     $params = array_merge($params, $query_params);
     ksort($params);
     $string_to_sign = "{$request_method}\n" . $request_path . "\n" . Pusher::array_implode('=', '&', $params);
     $auth_signature = hash_hmac('sha256', $string_to_sign, $auth_secret, false);
     $params['auth_signature'] = $auth_signature;
     ksort($params);
     $auth_query_string = Pusher::array_implode('=', '&', $params);
     return $auth_query_string;
 }
Ejemplo n.º 30
-5
 /**
  * Trigger the notification.
  *
  * @param \StyleCI\StyleCI\Models\Repo $repo
  * @param string                       $event
  *
  * @return void
  */
 protected function trigger(Repo $repo, $event)
 {
     $users = $this->userRepository->collaborators($repo);
     $data = AutoPresenter::decorate($repo)->toArray();
     foreach ($users as $user) {
         $this->pusher->trigger("user-{$user->id}", $event, ['event' => $data]);
     }
 }