1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace App\Workerman;
- use App\Http\Controllers\IndexController;
- use \GatewayWorker\Lib\Gateway;
- use Illuminate\Support\Facades\Log;
- use Workerman\Worker;
- class EventsTCP
- {
- // businessWorker进程启动事件
- public static function onWorkerStart($businessWorker)
- {
- // 开启一个内部端口,方便内部系统推送数据,Text协议格式 文本+换行符
- }
- //连接事件
- public static function onConnect($client_id)
- {
- // 向当前client_id发送数据
- Gateway::sendToClient($client_id, "TCP ".$client_id);
- }
- //进程退出事件
- public static function onWebSocketConnect($client_id, $data)
- {
- }
- //消息事件
- public static function onMessage($client_id, $message)
- {
- Log::error($message);
- // $re=new IndexController();
- // $re->JudgeMessage($client_id,$message);
- }
- // 连接断开事件
- public static function onClose($client_id)
- {
- }
- function broadcast($message)
- {
- global $worker;
- // foreach($worker->uidConnections as $connection)
- //
- // {
- //
- // $connection->send($message);
- //
- // }
- Gateway::sendToAll($message);
- }
- }
|