pushjs/php-sdk
Composer 安装命令:
composer require pushjs/php-sdk
包简介
A PHP library for pushjs.io
README 文档
README
Introduction
For basic usage, register at https://pushjs.io. This client provides a basic functionality to communicate with Javascript realtime!
The client can send messages in various formats (for example: JSON).
Example: if a user has a browser open with the PushJS javascript client loaded, a backend PHP script can communicate with
each other through our services. Yes, finally a PHP client that can communicate realtime to Javascript.
Examples
The basic initialization
<?php require "vendor/autoload.php"; use \Pushjs\Service\PushJS; $pushJS = new PushJS('your-api-key', 'eu-1.pushjs.io', 9101);
Dispatch event
Dispatching events in a channel means that every client in that particular channel will receive the event.
$pushJS->getEventManager()->dispatchEvent($channelId, 'MY_EVENT', json_encode([ 'text' => 'BOOM!', 'foo' => 'bar' ]) );
Dispatch a private event
This event will only reach the client with a specific id given in the $clientId.
$pushJS->getEventManager()->dispatchPrivateEvent( $clientId, 'MY_PRIVATE_MESSAGE_EVENT', 'this is a private message' );
Dispatch a filtered event
This event will only reach users with the attribute "red" and if it has the value "red".
$pushJS->getEventManager()->dispatchFilteredEvent( $channelId, 'MY_FILTERED_MESSAGE_EVENT', 'this should only go to to clients with attribute color and value red', ['color' => 'red'] );
统计信息
- 总下载量: 591
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-02-11