大佬們本地webman搞下來之后websocket控制臺連接測試失敗, 嘗試了各種姿勢 結(jié)果就是一個字 fail
class Websocket
{
public function onConnect(TcpConnection $connection){}
public function onWebSocketConnect(TcpConnection $connection, $http_buffer){}
public function onMessage(TcpConnection $connection, $data)
{
$data = json_decode($data, true);
// Timer::add(1, function() use ($return_ret, $connection, $data){
// // >>>>>>>>>>>>>>>>>>>>>>>
// // 處理代碼業(yè)務(wù)
// // >>>>>>>>>>>>>>>>>>>>>>>
//
// // 發(fā)送數(shù)據(jù) $return_ret 推送的數(shù)據(jù)
// $connection->send(json_encode($return_ret));
// });
$data=["code"=>0,'data'=>[1,2,3,4],'msg'=>'success'];
$connection->send(json_encode($data));
}
public function onClose(TcpConnection $connection)
{
// 關(guān)閉websocket
$connection->close();
}
}
http 打不開 websocket 也連不上 難道是我姿勢不對嗎
window
{
"name": "workerman/webman",
"type": "project",
"keywords": [
"high performance",
"http service"
],
"homepage": "http://www.wtbis.cn",
"license": "MIT",
"description": "High performance HTTP Service Framework.",
"authors": [
{
"name": "walkor",
"email": "walkor@workerman.net",
"homepage": "http://www.wtbis.cn",
"role": "Developer"
}
],
"support": {
"email": "walkor@workerman.net",
"issues": "https://github.com/walkor/webman/issues",
"forum": "https://wenda.workerman.net/",
"wiki": "https://workerman.net/doc/webman",
"source": "https://github.com/walkor/webman"
},
"require": {
"php": ">=7.2",
"workerman/webman-framework": "^1.5.0",
"monolog/monolog": "^2.0",
"webman/gateway-worker": "^1.0"
},
"suggest": {
"ext-event": "For better performance. "
},
"autoload": {
"psr-4": {
"": "./",
"app\\": "./app",
"App\\": "./app",
"app\\View\\Components\\": "./app/view/components"
},
"files": [
"./support/helpers.php"
]
},
"scripts": {
"post-package-install": [
"support\\Plugin::install"
],
"post-package-update": [
"support\\Plugin::install"
],
"pre-package-uninstall": [
"support\\Plugin::uninstall"
]
}
}