You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
895 B
48 lines
895 B
<?php
|
|
namespace app\push\controller;
|
|
|
|
use king\worker\Server;
|
|
|
|
class Worker extends Server
|
|
{
|
|
protected $socket = 'websocket://127.0.0.1:7272';
|
|
|
|
/**
|
|
* 收到消息
|
|
* @param $connection
|
|
* @param $data
|
|
*/
|
|
public function onMessage($connection, $data)
|
|
{
|
|
$connection->send('我收到你的信息了');
|
|
}
|
|
|
|
/**
|
|
* 连接时触发的回调函数
|
|
* @param $connection
|
|
*/
|
|
public function onConnect($connection)
|
|
{
|
|
file_put_contents('d:/msg','error',FILE_APPEND);
|
|
}
|
|
|
|
/**
|
|
* 当客户端的连接发生错误时触发
|
|
* @param $connection
|
|
* @param $code
|
|
* @param $msg
|
|
*/
|
|
public function onClose($connection, $code, $msg)
|
|
{
|
|
echo "error $code $msg\n";
|
|
}
|
|
|
|
/**
|
|
* 每个进程启动
|
|
* @param $worker
|
|
*/
|
|
public function onWorkerStart($worker)
|
|
{
|
|
|
|
}
|
|
} |