httpp886
- httpp886 2017-03-30 已签到连续签到4天,获得了20个金钱
- httpp886 2017-03-29 已签到连续签到3天,获得了15个金钱
- httpp886 2017-03-28 已签到连续签到2天,获得了10个金钱
- httpp886 2017-03-27 已签到连续签到1天,获得了5个金钱
- httpp886 2017-03-24 已签到连续签到1天,获得了5个金钱
- httpp886 评论了扩展 WorkerMan的推送 添加到YII2
php push.php start -d 少加了一个运行语句 在PUSH.PHP完成后运行
- httpp886 评论了扩展 WorkerMan的推送 添加到YII2
controllers 下添加PushController.php
<?php namespace backend\controllers; use Yii; use yii\web\Controller; class PushController extends Controller { /** * Renders the index view for the module * @return string */ public function actionWorker() { // 建立socket连接到内部推送端口 $client = stream_socket_client('tcp://192.168.85.128:5678', $errno, $errmsg, 1); // 推送的数据,包含uid字段,表示是给这个uid推送 echo 'ERRER:'.$errno.'='.$errmsg; $data = array('uid'=>'uid1', 'percent'=>'88%测试'); // 发送数据,注意5678端口是Text协议的端口,Text协议需要在数据末尾加上换行符 fwrite($client, json_encode($data)."\n"); // 读取推送结果 echo '$client=='.$client; echo fread($client, 8192); //return $this->render('index'); } }
views\layouts\main.php
下添加<script> var ws = new WebSocket('ws://10.20.1.39:1234'); ws.onopen = function(){ var uid = 'uid1'; ws.send(uid); }; ws.onmessage = function(e){ alert(e.data); }; </script>
这个内容组合到控制台的内容还在研究。完成后发布
- httpp886 2017-03-22 已签到连续签到3天,获得了15个金钱