1 Star 0 Fork 0

乎指南 / swoole4_ryloo_icu

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ws_server.php 615 Bytes
一键复制 编辑 原始数据 按行查看 历史
ryloo 提交于 2021-09-07 13:42 . 代码初始化
<?php
//创建WebSocket Server对象,监听0.0.0.0:9502端口
$ws = new Swoole\WebSocket\Server('0.0.0.0', 9502);
//监听WebSocket连接打开事件
$ws->on('Open', function ($ws, $request) {
$ws->push($request->fd, "hello, welcome\n");
});
//监听WebSocket消息事件
$ws->on('Message', function ($ws, $frame) {
echo "Message: {$frame->data}\n";
$ws->push($frame->fd, "server: {$frame->data}");
});
//监听WebSocket连接关闭事件
$ws->on('Close', function ($ws, $fd) {
echo "client-{$fd} is closed\n";
});
$ws->start();
1
https://gitee.com/ryloo/swoole4_ryloo_icu.git
git@gitee.com:ryloo/swoole4_ryloo_icu.git
ryloo
swoole4_ryloo_icu
swoole4_ryloo_icu
master

搜索帮助