Skip to content
This repository has been archived by the owner on Sep 1, 2020. It is now read-only.

Latest commit

 

History

History
11 lines (8 loc) · 388 Bytes

8.1.2 - onOpen.md

File metadata and controls

11 lines (8 loc) · 388 Bytes

onOpen

当WebSocket客户端与服务器建立连接并完成握手后会回调此函数。

function onOpen(swoole_websocket_server $svr, swoole_http_request $req);
  • $req 是一个Http请求对象,包含了客户端发来的握手请求信息
  • onOpen事件函数中可以调用push向客户端发送数据或者调用close关闭连接
  • onOpen事件回调是可选的