本文整理汇总了PHP中Pusher类的典型用法代码示例。如果您正苦于以下问题:PHP Pusher类的具体用法?PHP Pusher怎么用?PHP Pusher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Pusher类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:haya-sann,项目名称:INTER-Mediator,代码行数:8,代码来源:NotifyServer.php
示例2: testCanSubscribeMemberToPusherChannel
/**
* 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();
}
开发者ID:jahvi,项目名称:chatty,代码行数:12,代码来源:PusherAuthTest.php
示例3: 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;
}
开发者ID:RyuX51,项目名称:BABEL95,代码行数:14,代码来源:MessageSender.php
示例4: testSchemeIsStrippedAndIgnoredFromHostInOptions
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']);
}
开发者ID:jwwk-de,项目名称:pusher-http-php,代码行数:8,代码来源:pusherConstructorTest.php
示例5: 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));
}
开发者ID:brandon-bailey,项目名称:osdms,代码行数:9,代码来源:Notifications.php
示例6: 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']);
}
开发者ID:bryanashley,项目名称:framework,代码行数:17,代码来源:PusherBroadcaster.php
示例7: testEncryptedPush
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');
}
开发者ID:Arch1js,项目名称:Westcombe-Engineering-MRP-system,代码行数:10,代码来源:triggerBatchTest.php
示例8: 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);
}
开发者ID:pborreli,项目名称:composer-service,代码行数:10,代码来源:DumpFileStepSpec.php
示例9: 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);
}
开发者ID:NicolasMontoya,项目名称:SARA,代码行数:11,代码来源:Embedded.php
示例10: 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);
}
开发者ID:GregBrimble,项目名称:notablenews,代码行数:11,代码来源:update.php
示例11: it_push_error_message_and_alerts_when_vulnerability_found
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);
}
开发者ID:Omranic,项目名称:composer-service,代码行数:11,代码来源:CheckVulnerabilitiesStepSpec.php
示例12: pushToUser
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);
}
}
}
开发者ID:joyfulful,项目名称:DogBloodDonor_Web,代码行数:12,代码来源:push_functions.inc.php
示例13: _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;
}
开发者ID:hiiro,项目名称:twStreamViewer,代码行数:16,代码来源:streaming.php
示例14: 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.');
}
}
开发者ID:kai-cn,项目名称:bookcode-realtimewebapps,代码行数:26,代码来源:class.controller.inc.php
示例15: send_message
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;
}
开发者ID:raminv80,项目名称:CodeArmy,代码行数:21,代码来源:message_model.php
示例16: 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;
}
开发者ID:bizcoine,项目名称:ecoinstrader,代码行数:40,代码来源:Trade.php
示例17: 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;
}
开发者ID:jahvi,项目名称:new-order-notification,代码行数:28,代码来源:DisplayNotification.php
示例18: Server
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();
开发者ID:domraider,项目名称:rxnet,代码行数:31,代码来源:pusher.php
示例19: 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'));
}
开发者ID:scandesignsdk,项目名称:scangammon,代码行数:5,代码来源:Listener.php
示例20: pusherAuth
/**
* @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'));
}
开发者ID:adamstrawson,项目名称:BBMembershipSystem,代码行数:14,代码来源:SessionController.php
注:本文中的Pusher类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论