library swoole
輔助 Swoole 的工具
jsnlib/swoole
輔助 Swoole 的工具
- Thursday, April 5, 2018
- by fdjkgh580
- Repository
- 1 Watchers
- 0 Stars
- 40 Installations
- PHP
- 1 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 4 Versions
- 3 % Grown
swoole
輔助 Swoole 的工具, (*1)
用法
監聽 WebSocket 訊息事件, (*2)
$ws = new swoole_websocket_server("0.0.0.0", 8080);
$ws->on('message', function ($ws, $frame) {
\Jsnlib\Swoole::push_all([
'ws' => $ws,
'self' => $frame->fd,
'is_send_self' => false,
'data' => $frame->data
]);
});
參數說明
- ws:Websocket 物件
- self: 當前連接的對象
- is_send_self: 是否要發送給自己?建議使用 false
- data: 發送的數據