Conditions | 1 |
Paths | 1 |
Total Lines | 19 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
24 | public function trigger($channel, $message) |
||
25 | { |
||
26 | Debug::startStopwatch("notification.trigger.websocket"); |
||
27 | |||
28 | $port = \Service::getParameter('bzion.features.websocket.pull_port'); |
||
29 | |||
30 | $fp = @stream_socket_client("tcp://127.0.0.1:" . $port, $errno, $errstr, 1, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT); |
||
31 | |||
32 | @fwrite($fp, json_encode(array( |
||
|
|||
33 | 'event' => array( |
||
34 | 'type' => $channel, |
||
35 | 'data' => $message, |
||
36 | ) |
||
37 | )) . "\n"); |
||
38 | |||
39 | // Don't fclose() the connection because of a weird bug with React |
||
40 | |||
41 | Debug::finishStopwatch("notification.trigger.websocket"); |
||
42 | } |
||
43 | |||
56 |
If you suppress an error, we recommend checking for the error condition explicitly: