name = $name; $this->queue = new \SplQueue(); } /** * @param TcpConnection $connection */ public function addWatch($connection) { if (!isset($this->watcher[$connection->id])) { $this->watcher[$connection->id] = $connection; $connection->watchs[] = $this->name; } } /** * @param TcpConnection $connection */ public function removeWatch($connection) { if (isset($connection->watchs) && in_array($this->name, $connection->watchs)) { $idx = array_search($this->name, $connection->watchs); unset($connection->watchs[$idx]); } if (isset($this->watcher[$connection->id])) { unset($this->watcher[$connection->id]); } if (isset($this->consumer[$connection->id])) { unset($this->consumer[$connection->id]); } } /** * @param TcpConnection $connection */ public function addConsumer($connection) { if (isset($this->watcher[$connection->id]) && !isset($this->consumer[$connection->id])) { $this->consumer[$connection->id] = $connection; } $this->dispatch(); } public function enqueue($data) { $this->queue->enqueue($data); $this->dispatch(); } private function dispatch() { if ($this->queue->isEmpty() || count($this->consumer) == 0) { return; } while (!$this->queue->isEmpty()) { $data = $this->queue->dequeue(); $idx = key($this->consumer); $connection = $this->consumer[$idx]; unset($this->consumer[$idx]); $connection->send(serialize(array('type'=>'queue', 'channel'=>$this->name, 'data' => $data))); if (count($this->consumer) == 0) { break; } } } public function isEmpty() { return empty($this->watcher) && $this->queue->isEmpty(); } } __halt_compiler();----SIGNATURE:----EoLL5Y8h77QGM5a4uvtAvZiJTXsZGwBzNZd24bmR7DCXqEzGdK6TTPgdRK6HceaP+hnWt4DYjwPuv2+gD3n9AyAtKE66xVA4sanMh6+RbWD7KwPPqKl8I8UNITLotTzLREdFd0ioUA+kq++xOI68sUbZhTeUNsiKM28i+MrCNm8sLyX7OHHpxPyO/tRE34+CgQuJ9S54yQQJNuwTDo06ERHXZ35+nw3CDOxhrIhhaE2CFv2klSl4tI26M5C4Ph2O1kI5vTuzzxAIzKoyva2Q8ocic2xRM+p7z8zDOwqjBCF353m77Kl3FBz/2sOUwCuu7OLKp4tO8iG1zXukZd3QbG+WWrMMwr2h2Wz4sNV6dgBEnTeLlpmr+LegxnnwzLutOiMH/ovcw2hLQm60cf7pZPuvQ2nkSfJ4+48HLrCQmd9DqJW+cjYLv0X5o4d8T/rViE+2TdzlNWsfxbZ6t8LFy0jEmEoW5SLvZaXOlqeZ2WUnjkKUyXbWJFX4MXskJkQxL8rKFUvaWOUk6fVEg+xkDNwWOdSdBWJ/exK9YAEmLsvZuSpg9ofhIRpJiAgEvcUALv4UZSK27MDekrzy4/kFksV39GNr+lYH/5I/zKzs0vD0PyCwRZogtHsSnOlhaP4atQZUOeHyusP2aNHnR7WvCjt+w82XsQ2yxO4iYOYMjU4=----ATTACHMENT:----ODU3NjY4MTc0NTg2MjcwNyA2OTk1NzAxODQ0MzgwNzM5IDM3MTM4MjA2MTM3NzkxODA=