本文整理匯總了PHP中Pusher::trigger方法的典型用法代碼示例。如果您正苦於以下問題:PHP Pusher::trigger方法的具體用法?PHP Pusher::trigger怎麽用?PHP Pusher::trigger使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Pusher
的用法示例。
在下文中一共展示了Pusher::trigger方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: deleted
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);
}
示例2: deleteGame
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'));
}
示例3: broadcast
/**
* 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']);
}
示例4: array
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);
}
示例5: sendMessage
/**
*
* @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;
}
示例6: newNotification
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));
}
示例7: it_dump_composer_json_content_to_file
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);
}
示例8: ready
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);
}
示例9: push
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);
}
示例10: _callback
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;
}
示例11: handle_form_submission
/**
* 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.');
}
}
示例12: array
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;
}
示例13: addTradeHistory
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;
}
示例14: execute
/**
* 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;
}
示例15: setDefaults
<?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}'";