mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-02-22 22:20:46 +00:00
Update LiveStream events
This commit is contained in:
parent
b55e91d1e3
commit
4630c5d67a
3 changed files with 11 additions and 13 deletions
|
@ -9,22 +9,21 @@ use Illuminate\Broadcasting\PrivateChannel;
|
||||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
use Illuminate\Foundation\Events\Dispatchable;
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use App\Models\LiveStream;
|
|
||||||
|
|
||||||
class StreamEnd implements ShouldBroadcast
|
class StreamEnd implements ShouldBroadcast
|
||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
public $livestream;
|
public $id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(LiveStream $livestream)
|
public function __construct($id)
|
||||||
{
|
{
|
||||||
$this->livestream = $livestream;
|
$this->id = $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,7 +33,7 @@ class StreamEnd implements ShouldBroadcast
|
||||||
*/
|
*/
|
||||||
public function broadcastOn()
|
public function broadcastOn()
|
||||||
{
|
{
|
||||||
return new PrivateChannel('live.chat.' . $this->livestream->profile_id);
|
return new PrivateChannel('live.chat.' . $this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function broadcastAs()
|
public function broadcastAs()
|
||||||
|
|
|
@ -9,22 +9,21 @@ use Illuminate\Broadcasting\PrivateChannel;
|
||||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
use Illuminate\Foundation\Events\Dispatchable;
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use App\Models\LiveStream;
|
|
||||||
|
|
||||||
class StreamStart implements ShouldBroadcast
|
class StreamStart implements ShouldBroadcast
|
||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
public $livestream;
|
public $id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(LiveStream $livestream)
|
public function __construct($id)
|
||||||
{
|
{
|
||||||
$this->livestream = $livestream;
|
$this->id = $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,7 +33,7 @@ class StreamStart implements ShouldBroadcast
|
||||||
*/
|
*/
|
||||||
public function broadcastOn()
|
public function broadcastOn()
|
||||||
{
|
{
|
||||||
return new PrivateChannel('live.chat.' . $this->livestream->profile_id);
|
return new PrivateChannel('live.chat.' . $this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function broadcastAs()
|
public function broadcastAs()
|
||||||
|
|
|
@ -147,7 +147,7 @@ class LiveStreamController extends Controller
|
||||||
->each(function($stream) {
|
->each(function($stream) {
|
||||||
Storage::deleteDirectory("public/live-hls/{$stream->stream_id}");
|
Storage::deleteDirectory("public/live-hls/{$stream->stream_id}");
|
||||||
LiveStreamService::clearChat($stream->profile_id);
|
LiveStreamService::clearChat($stream->profile_id);
|
||||||
StreamEnd::dispatch($stream);
|
StreamEnd::dispatch($stream->profile_id);
|
||||||
$stream->delete();
|
$stream->delete();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -377,7 +377,7 @@ class LiveStreamController extends Controller
|
||||||
$stream->live_at = now();
|
$stream->live_at = now();
|
||||||
$stream->save();
|
$stream->save();
|
||||||
|
|
||||||
StreamStart::dispatch($stream);
|
StreamStart::dispatch($stream->profile_id);
|
||||||
return [];
|
return [];
|
||||||
} else {
|
} else {
|
||||||
abort(400);
|
abort(400);
|
||||||
|
@ -394,7 +394,7 @@ class LiveStreamController extends Controller
|
||||||
$name = $url['name'] ?? $request->input('name');
|
$name = $url['name'] ?? $request->input('name');
|
||||||
|
|
||||||
$stream = LiveStream::whereStreamId($name)->whereStreamKey($url['key'])->firstOrFail();
|
$stream = LiveStream::whereStreamId($name)->whereStreamKey($url['key'])->firstOrFail();
|
||||||
StreamEnd::dispatch($stream);
|
StreamEnd::dispatch($stream->profile_id);
|
||||||
LiveStreamService::clearChat($stream->profile_id);
|
LiveStreamService::clearChat($stream->profile_id);
|
||||||
|
|
||||||
if(config('livestreaming.broadcast.delete_token_after_finished')) {
|
if(config('livestreaming.broadcast.delete_token_after_finished')) {
|
||||||
|
|
Loading…
Reference in a new issue