1 | <?php |
||
12 | class MemoryCollector implements StatisticsCollector |
||
13 | { |
||
14 | /** |
||
15 | * The list of stored statistics. |
||
16 | * |
||
17 | * @var array |
||
18 | */ |
||
19 | protected $statistics = []; |
||
20 | |||
21 | /** |
||
22 | * The Channel manager. |
||
23 | * |
||
24 | * @var \BeyondCode\LaravelWebSockets\Contracts\ChannelManager |
||
25 | */ |
||
26 | protected $channelManager; |
||
27 | |||
28 | /** |
||
29 | * Initialize the logger. |
||
30 | * |
||
31 | * @return void |
||
|
|||
32 | */ |
||
33 | public function __construct() |
||
37 | |||
38 | /** |
||
39 | * Handle the incoming websocket message. |
||
40 | * |
||
41 | * @param string|int $appId |
||
42 | * @return void |
||
43 | */ |
||
44 | public function webSocketMessage($appId) |
||
49 | |||
50 | /** |
||
51 | * Handle the incoming API message. |
||
52 | * |
||
53 | * @param string|int $appId |
||
54 | * @return void |
||
55 | */ |
||
56 | public function apiMessage($appId) |
||
61 | |||
62 | /** |
||
63 | * Handle the new conection. |
||
64 | * |
||
65 | * @param string|int $appId |
||
66 | * @return void |
||
67 | */ |
||
68 | public function connection($appId) |
||
73 | |||
74 | /** |
||
75 | * Handle disconnections. |
||
76 | * |
||
77 | * @param string|int $appId |
||
78 | * @return void |
||
79 | */ |
||
80 | public function disconnection($appId) |
||
85 | |||
86 | /** |
||
87 | * Save all the stored statistics. |
||
88 | * |
||
89 | * @return void |
||
90 | */ |
||
91 | public function save() |
||
111 | |||
112 | /** |
||
113 | * Flush the stored statistics. |
||
114 | * |
||
115 | * @return void |
||
116 | */ |
||
117 | public function flush() |
||
121 | |||
122 | /** |
||
123 | * Get the saved statistics. |
||
124 | * |
||
125 | * @return PromiseInterface[array] |
||
126 | */ |
||
127 | public function getStatistics(): PromiseInterface |
||
131 | |||
132 | /** |
||
133 | * Get the saved statistics for an app. |
||
134 | * |
||
135 | * @param string|int $appId |
||
136 | * @return PromiseInterface[\BeyondCode\LaravelWebSockets\Statistics\Statistic|null] |
||
137 | */ |
||
138 | public function getAppStatistics($appId): PromiseInterface |
||
144 | |||
145 | /** |
||
146 | * Find or create a defined statistic for an app. |
||
147 | * |
||
148 | * @param string|int $appId |
||
149 | * @return \BeyondCode\LaravelWebSockets\Statistics\Statistic |
||
150 | */ |
||
151 | protected function findOrMake($appId): Statistic |
||
159 | |||
160 | /** |
||
161 | * Create a new record using the Statistic Store. |
||
162 | * |
||
163 | * @param \BeyondCode\LaravelWebSockets\Statistics\Statistic $statistic |
||
164 | * @param mixed $appId |
||
165 | * @return void |
||
166 | */ |
||
167 | public function createRecord(Statistic $statistic, $appId) |
||
171 | } |
||
172 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.