我的需求是:
ws://192.168.10.45:20003/?token=123
獲取token參數(shù),但是沒有找到相關(guān)函數(shù),
然后發(fā)現(xiàn)TcpConnection有g(shù)etSocket()函數(shù)
通這個函數(shù)可以file_put_contents下載下來然后就可以正則拿到token了
但是我想直接getSocket()函數(shù)拿到資源打印出來直接正則好像不行,不知道怎么打印socket資源?
我想直接getHandToken(getSocket())不行~
我改怎么把getSocket()轉(zhuǎn)成字符串呢?麻煩各位大佬了
根據(jù)文檔這里,http://doc.workerman.net/appendices/about-websocket.html
onWebSocketConnect 里可以獲得 http_header
$ws = new Worker('websocket://0.0.0.0:8181');
$ws->onConnect = function($connection)
{
$connection->onWebSocketConnect = function($connection , $http_header)
{
var_dump($http_header);
};
};