Sockets   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 29
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A broadcastOn() 0 4 1
A __construct() 0 6 1
1
<?php
2
3
/*
4
  Author: UP805717 (springjben)
5
  
6
  This file is used for Laravel events. Its main purpose being to communcate the framework with the node server.
7
  This event is fired off when a quiz host wants to start a quiz
8
*/
9
10
namespace App\Events;
11
12
use Illuminate\Broadcasting\Channel;
13
use Illuminate\Queue\SerializesModels;
14
use Illuminate\Broadcasting\PrivateChannel;
15
use Illuminate\Broadcasting\PresenceChannel;
16
use Illuminate\Foundation\Events\Dispatchable;
17
use Illuminate\Broadcasting\InteractsWithSockets;
18
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
19
20
class Sockets implements ShouldBroadcast
21
{
22
    use Dispatchable, InteractsWithSockets, SerializesModels;
0 ignored issues
show
introduced by
The trait Illuminate\Queue\SerializesModels requires some properties which are not provided by App\Events\Sockets: $id, $class, $connection
Loading history...
23
    public $questionData;
24
    /**
25
     * Create a new event instance.
26
     *
27
     * @return void
28
     */
29
30
    //This creates an event that is fired off to the redis server so that Laravel can communicate with the node server (and web sockets)
31
    public function __construct($pin, $method)
32
    {
33
        //Each class will contain the answers and so forth..
34
        $this->questionData = array(
35
             'pin' => $pin,
36
             'method' => $method
37
         );
38
    }
39
40
    /**
41
     * Get the channels the event should broadcast on.
42
     *
43
     * @return \Illuminate\Broadcasting\Channel|array
44
     */
45
     public function broadcastOn()
46
     {
47
         //Upon broadcasting (event firing off) it returns the channel. Please see the main socket.io file for more information about the redis subscriptions
48
         return ['questions'];
49
     }
50
}
51