Files
chatroom/routes/channels.php
lkddi 50fc804402 feat: 实现挂机修仙、排行榜、大厅重构与全站留言板系统
- (Phase 8) 后台各维度管理与配置
- (Phase 9) 全自动静默挂机修仙升级
- (Phase 9) 四大维度风云排行榜页面
- (Phase 10) 全站留言板与悄悄话私信功能
- 运行 Pint 代码格式化
2026-02-26 13:35:38 +08:00

24 lines
926 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
use Illuminate\Support\Facades\Broadcast;
Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
return (int) $user->id === (int) $id;
});
// 聊天室房间 Presence Channel 鉴权与成员信息抓取
Broadcast::channel('room.{roomId}', function ($user, $roomId) {
// 这里未来可以增加判断:比如该房间是否被锁定,或者该用户是否在此房间的黑名单中
// 凡是通过了这个判断的人(返回一个数组),他就会成功建立 WebSocket
// 且他的这个数组信息会被 Reverb 推送给这个房间内的所有其他人 (joining / here 事件)。
return [
'id' => $user->id,
'username' => $user->username,
'user_level' => $user->user_level,
'sex' => $user->sex,
'headface' => $user->headface,
// 这里可以视情况加入更多需要前端渲染在线人员列表的字段
];
});