1 | <?php |
||
26 | class ListenerPooler extends ClientPooler |
||
27 | { |
||
28 | /** |
||
29 | * getPoolerType |
||
30 | * |
||
31 | * @see ClientPoolerInterface |
||
32 | */ |
||
33 | public function getPoolerType() |
||
37 | |||
38 | |||
39 | /** |
||
40 | * createClient |
||
41 | * |
||
42 | * See @ClientPooler |
||
43 | */ |
||
44 | protected function createClient($identifier) |
||
48 | |||
49 | /** |
||
50 | * notify |
||
51 | * |
||
52 | * Send a notification to clients. |
||
53 | * Client identifiers may be a single client name, an array of client or |
||
54 | * '*' to notify all clients. |
||
55 | * Event name may use ':' to split indicate additional information (ie type |
||
56 | * of payload). Events sent to 'pika', 'pika:chu' will both notify client |
||
57 | * 'pika'. |
||
58 | * |
||
59 | * @access public |
||
60 | * @param string|array $identifiers |
||
61 | * @param array $data |
||
62 | * @return ListenerPooler $this |
||
63 | */ |
||
64 | public function notify($identifiers, array $data) |
||
84 | |||
85 | /** |
||
86 | * notifyAll |
||
87 | * |
||
88 | * Notify all existing clients. |
||
89 | * |
||
90 | * @access protected |
||
91 | * @param array $data |
||
92 | * @return ListenerPooler $this |
||
93 | */ |
||
94 | protected function notifyAll(array $data) |
||
95 | { |
||
96 | foreach ($this |
||
97 | ->getSession() |
||
98 | ->getAllClientForType($this->getPoolerType()) as $client) { |
||
99 | $client->notify('*', $data); |
||
100 | } |
||
101 | |||
102 | return $this; |
||
103 | } |
||
104 | |||
105 | /** |
||
106 | * notifyClients |
||
107 | * |
||
108 | * Send a notification to the specified clients. |
||
109 | * |
||
110 | * @access protected |
||
111 | * @param array $identifiers |
||
112 | * @param array $data |
||
113 | * @return ListenerPooler $this |
||
114 | */ |
||
115 | protected function notifyClients(array $identifiers, array $data) |
||
135 | } |
||
136 |