当前位置: 首页 > news >正文

laraval6.0 GatewayWorker 交互通信

laravel 6.0 GatewayWorker 通讯

  • 开发前准备
    • 下载 GatewayWorker 及操作方式
    • 前端demo
    • 测试效果
    • 项目中安装GatewayClient

开发前准备

GatewayClient 官网:https://www.workerman.net/
当前使用的是宝塔操作

下载 GatewayWorker 及操作方式

在这里插入图片描述

前端demo

在这里插入图片描述

测试效果

在这里插入图片描述

项目中安装GatewayClient

在这里插入图片描述

composer require workerman/gatewayclient

在这里插入图片描述
绑定用户 和 消息推送

<?phpnamespace App\Http\Controllers\Common;use App\Exceptions\Exception\ErrorException;
use GatewayClient\Gateway;require_once '../vendor/workerman/gatewayclient/Gateway.php';class Push
{public function __construct(){//注意:127.0.0.1:1238 的1238端口不是随意填写的 是在GatewayWorker/yourApp/start_gateway.php 里面//$gateway->registerAddress = '127.0.0.1:1238'; 配置的Gateway::$registerAddress = '127.0.0.1:1238';}/*** Notes:  绑定用户* Author: Seven* Method: getUserBinding* Date: 2023/11/29: 17:27* @param $client_id* @param $users_id*/public function getUserBinding($param){if(empty($param['client_id'])) throw new ErrorException('缺少 client_id');if(empty($param['users_id'])) throw new ErrorException('缺少 users_id');Gateway::bindUid($param['client_id'],$param['users_id']);dd($param['client_id']);}/*** Notes:  推送信息* Author: Seven* Method: getSendPush* Date: 2023/11/29: 17:42* @param $users_id* @param $content*/public function getSendPush($users_id,$type,$content){$data = ['type'=>$type,'msg'=>$content,];Gateway::sendToUid($users_id,json_encode($data));}}

查看结果
调用推送的接口
在这里插入图片描述
到这里说明已经交互成功

http://www.lryc.cn/news/248566.html

相关文章:

  • 循环神经网络RNN
  • 为什么预处理对象会提升处理的性能
  • 智能超声波雾化器pcba方案
  • Git分支合并导致文件异常
  • Linux(11):Linux 账号管理与 ACL 权限设定
  • AMEYA360:村田首款1608M尺寸/100V静电容量1µF的MLCC实现商品化
  • 简易键值对文本解析
  • 成为AI产品经理——模型评估(混淆矩阵)
  • Git_git相关指令 高阶
  • PC企业微信http协议逆向接口开发,发送大视频文件
  • hyper-V操作虚拟机ubuntu 22.03
  • Spring boot命令执行 (CVE-2022-22947)漏洞复现和相关利用工具
  • 代理模式-C++实现
  • 从 0 到 1 开发一个 node 命令行工具
  • VsCode中使用功能vite创建vue3+js项目报错
  • COGVLM论文解读(COGVLM:VISUAL EXPERT FOR LARGE LANGUAGE MODELS)
  • Flink-时间流与水印
  • BiLSTM-CRF的中文命名实体识别
  • paddle detection 训练参数
  • 用bat制作图片马——一句话木马
  • json_encode() 返回 false
  • Android-Jetpack--Hilt详解
  • Docker 下载加速
  • 1091 Acute Stroke (三维搜索)
  • java elasticsearch 桶聚合(bucket)
  • 【人生苦短,我学 Python】(4)Python 常用内置数据类型 II —— 序列数据类型(str、tuple、list、bytes和bytearray)
  • Android 9.0 系统默认显示电量百分比
  • 原神:夏洛蒂是否值得培养?全队瞬抬治疗量不输五星,但缺点也很明显
  • Sublime text 添加到鼠标右键菜单,脚本实现
  • 【算法】离散化 与 哈希 之间的区别