Optionally provide a socket ID to exclude a client (most likely the sender).
public trigger ( array $channels, string $event, mixed $data, string $socket_id = null, boolean $debug = false, boolean $already_encoded = false ) : boolean | string | ||
$channels | array | An array of channel names to publish the event on. |
$event | string | |
$data | mixed | Event data |
$socket_id | string | [optional] |
$debug | boolean | [optional] |
$already_encoded | boolean | [optional] |
return | boolean | string |
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); }
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')); }
/** * 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']); }
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); }
/** * * @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 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)); }
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 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); }
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 _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.'); } }
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; }
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; }
<?php require_once '../config.class.php'; require_once 'Pusher.php'; require_once 'pusher_defaults.php'; if (isset($_REQUEST['default'])) { setDefaults($_REQUEST['default']); } $channel = isset($_REQUEST['channel']) ? $_REQUEST['channel'] : $default_channel; $event = isset($_REQUEST['event']) ? $_REQUEST['event'] : $default_event; $data = isset($_REQUEST['data']) ? $_REQUEST['data'] : $default_data; $pusher = new Pusher(Config::pusher_key, Config::pusher_secret, Config::pusher_app_id, true); $pusher->trigger($channel, $event, $data); echo "Channel: '{$channel}', Event: '{$event}', Data: '{$data}'";
function chat_send(){ $user_id = $this->session->userdata('user_id'); $this->load->helper('htmlpurifier'); if($id=$user_id){ $msg = html_purify($this->input->post('message')); require_once(getcwd()."/application/helpers/pusher/Pusher.php"); $pusher = new Pusher('deb0d323940b00c093ee', '9ab20336af22c4e7fa77', '25755'); $data = array( 'user_id' => $user_id, 'username' => $this->view_data['me']['username'], 'message' => $msg ); $pusher->trigger('presence-chat-public', 'incomming-message', $data ); echo $msg; } }
/** * Trigger an event by providing event name and payload. * Optionally provide a socket ID to exclude a client (most likely the sender). * * @param array $channels An array of channel names to publish the event on. * @param string $event * @param mixed $data Event data * @param string $socket_id [optional] * @param bool $debug [optional] * @return bool|string */ public function push($channels, $event, $data, $socket_id = null, $debug = false, $already_encoded = false) { return $this->_pusher->trigger($channels, $event, $data, $socket_id, $debug, $already_encoded); }
/** * {@inheritdoc} */ public function broadcast(array $channels, $event, array $payload = []) { $this->pusher->trigger($channels, $event, $payload); }
/** * Triggers a "consumer:vulnerabilities" message on Pusher. * * @param ConsumerEvent $event * @param array $message */ protected function triggerVulnerabilities(ConsumerEvent $event, $message) { $this->pusher->trigger($this->getChannels($event), 'consumer:vulnerabilities', $message); }
<?php require 'Pusher.php'; $key = '8bb3cacf5137c936bec5'; $secret = 'd347d6199a70fb6a2b3f'; $app_id = '166707'; $pusher = new Pusher($key, $secret, $app_id); if ($_POST) { $message = $_POST['message']; $username = $_POST['username']; $pusher->trigger('test_channel', 'my_event', array('username' => $username, 'message' => $message, 'time' => date("Y-m-d H:i:s"))); // echo 'yes'; }
function log_history($user_id,$work_id,$event,$status,$desc,$push=true){ $user = $this->db->get_where('users',array('user_id'=>$user_id))->result_array(); $user = $user[0]; $work = $this->db->get_where('works',array('work_id'=>$work_id))->result_array(); $work = $work[0]; $data = array( 'user_id' => $user_id, 'work_id' => $work_id, 'Desc' => $desc, 'event' => $event, 'status' => $status ); $this->db->insert('history',$data); if($push){ require_once(getcwd()."/application/helpers/pusher/Pusher.php"); $pusher = new Pusher('deb0d323940b00c093ee', '9ab20336af22c4e7fa77', '25755'); $data = array( 'user_id' => $user_id, 'username' => $user['username'], 'work_id' => $work_id, 'work_title'=>$work['title'], 'Desc' => $desc, 'event' => $event, 'time' => date('h:ia, d/m/Y'), 'status' => $status, 'event_id'=> $this->db->insert_id() ); $pusher->trigger('history', 'new-activity-'.$work_id, $data ); } }
<?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(-1); if (isset($_POST['event'])) { require __DIR__ . '/vendor/autoload.php'; $app_id = '121769'; $app_key = 'a5a36045c48396dce7ed'; $app_secret = 'c5bae0ddd50a541b9c14'; $pusher = new Pusher($app_key, $app_secret, $app_id); $pusher->trigger('messages', $_POST['event'], ''); exit; } ?> <!DOCTYPE html> <html> <head> <title>All the Buzzwords - (React/Flux/Parse)</title> <meta name="viewport" content="initial-scale=1.0,width=device-width,user-scalable=0" /> <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet"> <meta name="apple-mobile-web-app-capable" content="yes"> <link rel="stylesheet" type="text/css" href="/public/css/main.css"> </head> <body> <script src="//js.pusher.com/2.2/pusher.min.js"></script> <script type="text/javascript" src="http://www.parsecdn.com/js/parse-1.4.2.min.js"></script> <script type="text/javascript" src="/public/js/app.min.js"></script>
<?php require 'vendor/autoload.php'; // include Composer goodies require_once 'event_render.php'; session_start(); $_POST['user_id'] = $_SESSION['fb_user_id']; $m = new MongoClient(); $m->sports->events->insert($_POST); $app_id = '160654'; $app_key = 'b227f5df488b51be2735'; $app_secret = '4fd04b73ede5c049508e'; $pusher = new Pusher($app_key, $app_secret, $app_id, array('encrypted' => true)); $mes = render_event($_POST); $pusher->trigger('events_channel', 'my_event', $mes); echo 'Created event'; header("Location: http://" . $_SERVER['SERVER_NAME'] . "/SportsBuddy/viewevents.php");
public function remove_comment_v5($id){ $comment = $this->stories->get_comment($id); if(count($comment)>0){ if(($comment[0]['username']==$this->session->userdata('username'))||($this->session->userdata('role')=='admin')){ $this->stories->delete_comment($id); //pusher require_once(getcwd()."/application/helpers/pusher/Pusher.php"); $pusher = new Pusher('0aacc348a446e96739e2', 'f63f88767155269e4c98', '18954'); $data = array( 'comment'=> $id, 'story_id' => $comment[0]['story_id'] ); $pusher->trigger('test_channel', 'remove_comment_'.$comment[0]['story_id'], $data); } } }
setXsrfCookie("/"); if (empty($id) === false) { $reply->data = Misquote::getMisquoteByMisquoteId($pdo, $id); } else { $reply->data = Misquote::getAllMisquotes($pdo)->toArray(); } // put to an existing Misquote } else { if ($method === "PUT") { // convert PUTed JSON to an object verifyXsrf(); $requestContent = file_get_contents("php://input"); $requestObject = json_decode($requestContent); $misquote = new Misquote($id, $requestObject->attribution, $requestObject->misquote, $requestObject->submitter); $misquote->update($pdo); $pusher->trigger("misquote", "update", $misquote); $reply->message = "Misquote updated OK"; // post to a new Misquote } else { if ($method === "POST") { // convert POSTed JSON to an object verifyXsrf(); $requestContent = file_get_contents("php://input"); $requestObject = json_decode($requestContent); $misquote = new Misquote(null, $requestObject->attribution, $requestObject->misquote, $requestObject->submitter); $misquote->insert($pdo); $pusher->trigger("misquote", "new", $misquote); $reply->message = "Misquote created OK"; // delete an existing Misquote } else { if ($method === "DELETE") {
/** * 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); }
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'); }
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'); }
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"; } }
/** * 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]); } }