53 lines
1.3 KiB
PHP
53 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Events;
|
|
|
|
use Illuminate\Broadcasting\Channel;
|
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
|
use Illuminate\Foundation\Events\Dispatchable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class PerceptronTrainingIteration implements ShouldBroadcast
|
|
{
|
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
|
|
|
/**
|
|
* Create a new event instance.
|
|
*/
|
|
public function __construct(
|
|
public int $iteration,
|
|
public int $exampleIndex,
|
|
public float $error,
|
|
public array $synaptic_weights,
|
|
public string $sessionId,
|
|
)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Get the channels the event should broadcast on.
|
|
*
|
|
* @return array<int, \Illuminate\Broadcasting\Channel>
|
|
*/
|
|
public function broadcastOn(): array
|
|
{
|
|
// Log::debug("Broadcasting on channel: " . $this->sessionId . '-perceptron-training');
|
|
return [
|
|
new Channel($this->sessionId . '-perceptron-training'),
|
|
];
|
|
}
|
|
|
|
public function broadcastWith(): array
|
|
{
|
|
return [
|
|
'iteration' => $this->iteration,
|
|
'exampleIndex' => $this->exampleIndex,
|
|
'error' => $this->error,
|
|
'synaptic_weights' => $this->synaptic_weights,
|
|
];
|
|
}
|
|
}
|