jsnlib/swoole

辅助 Swoole 的工具

1.1.1 2018-04-05 15:07 UTC

This package is auto-updated.

Last update: 2024-08-29 04:31:30 UTC


README

辅助 Swoole 的工具

用法

监听 WebSocket 消息事件

$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: 发送的数据