定制 pushjs/php-sdk 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-02-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固