*/ public function broadcastOn(): array { return [ new PresenceChannel('room.'.$this->roomId), ]; } /** * 获取广播时的数据 * * @return array */ public function broadcastWith(): array { $statusMessage = $this->muteTime > 0 ? "用户 [{$this->username}] 已被系统封口 {$this->muteTime} 次发言时间。" : "用户 [{$this->username}] 已被解除封口。"; return [ 'username' => $this->username, 'mute_time' => $this->muteTime, 'message' => $statusMessage, ]; } }