當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Pusher類代碼示例

本文整理匯總了PHP中Pusher的典型用法代碼示例。如果您正苦於以下問題:PHP Pusher類的具體用法?PHP Pusher怎麽用?PHP Pusher使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Pusher類的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);
 }
開發者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


注:本文中的Pusher類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。