the browser-facing portion of osu!
at master 1.3 kB view raw
1<?php 2 3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0. 4// See the LICENCE file in the repository root for full licence text. 5 6namespace App\Events; 7 8use Illuminate\Broadcasting\Channel; 9 10class UserSessionEvent extends NotificationEventBase 11{ 12 private function __construct(public $action, public $userId, public $data) 13 { 14 parent::__construct(); 15 } 16 17 public static function newLogout($userId, $keys) 18 { 19 return new static('logout', $userId, compact('keys')); 20 } 21 22 public static function newVerificationRequirementChange($userId, $isRequired) 23 { 24 return new static('verification_requirement_change', $userId, [ 25 'requires_verification' => $isRequired, 26 ]); 27 } 28 29 public static function newVerified($userId, $key) 30 { 31 return new static('verified', $userId, compact('key')); 32 } 33 34 public function broadcastAs() 35 { 36 return $this->action; 37 } 38 39 /** 40 * Get the channels the event should broadcast on. 41 * 42 * @return Channel|array 43 */ 44 public function broadcastOn() 45 { 46 return new Channel("user_session:{$this->userId}"); 47 } 48 49 public function broadcastWith() 50 { 51 return $this->data; 52 } 53}