本文整理汇总了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);
}
示例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();
}
示例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;
}
示例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']);
}
示例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));
}
示例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']);
}
示例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');
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
}
示例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;
}
示例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.');
}
}
示例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;
}