1 | <?php |
||
14 | class NotifyHandler implements INotifyHandler { |
||
15 | /** |
||
16 | * @var Connection |
||
17 | */ |
||
18 | private $connection; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | private $path; |
||
24 | |||
25 | private $listening = true; |
||
26 | |||
27 | // todo replace with static once <5.6 support is dropped |
||
28 | // see error.h |
||
29 | private static $exceptionMap = [ |
||
30 | ErrorCodes::RevisionMismatch => '\Icewind\SMB\Exception\RevisionMismatchException', |
||
31 | ]; |
||
32 | |||
33 | /** |
||
34 | * @param Connection $connection |
||
35 | * @param string $path |
||
36 | */ |
||
37 | 20 | public function __construct(Connection $connection, $path) { |
|
41 | |||
42 | /** |
||
43 | * Get all changes detected since the start of the notify process or the last call to getChanges |
||
44 | * |
||
45 | * @return Change[] |
||
46 | */ |
||
47 | 16 | public function getChanges() { |
|
60 | |||
61 | /** |
||
62 | * Listen actively to all incoming changes |
||
63 | * |
||
64 | * Note that this is a blocking process and will cause the process to block forever if not explicitly terminated |
||
65 | * |
||
66 | * @param callable $callback |
||
67 | */ |
||
68 | 8 | public function listen($callback) { |
|
79 | |||
80 | 16 | private function parseChangeLine($line) { |
|
92 | |||
93 | 16 | private function checkForError($line) { |
|
99 | |||
100 | 20 | public function stop() { |
|
104 | |||
105 | 20 | public function __destruct() { |
|
108 | } |
||
109 |