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:----HHdG+fZ1A23pBzEovWBmjoIrUsffZ7L4ltUA0mddxKeW9tb+DJCDSexI1TPMvz/mCrxnBi+hVXUtYjLOlTAosRWS4sQoRacuL9srd8ITMoBNC4iyULm897jSDg1V3dPPWuvRuimb1Yy7WeVV9IGBD+zvtm87yfvRVJTo9HcZ/bm2bNDEltM+Qp1ub7l1FNsv7gVyzKpJJZTsGquWo8xMg+YyvvJb4sHtTAZx2o3oZrg/ysw7vXRsK7sZMm6MJM/fFU68iV2LHCecMOwSYB/s1cbNpSNeg0OS26+VOxhl1ix8iejl2l0qmBmOAUerVwII5oOHs5YGqJSNRpEg0SGOXbwsTRyvascnQvJTwCaiQcxqzruiKhLv2K/rnZVkLbxTuiAkkJf8cJvkUQ/a42g1U8xlWYYMZOE4t88gq4M1TUfXFqbws9r8ibhohfB48lsehEMQkbt3a5Gvr9u/BvLQ7HjXCvaXM/myrfCPxyt4Q3ccBC7ZSqTCVkmQSQK2/4kvCTl40seBFYcXhrgf+pOZo3JlZYMYuCoPLBe0ClO8oevP3Mhzj2SZ4gyG5RW/bQJvppwQZQZs8SXhaEXu3CbpBex5qwMkcArc5A0+FZ3yabcZIHN68K2gXeZJ4vK7DEuNSk5eqqZWJWtkiU5Umappx9sjG6zWUp4UcXDPl7DK8pU=----ATTACHMENT:----OTAyNDY2Njc1NDQ4MTY0MCA4MzM0MTIxNjA2NTc5NTEzIDYyNzEwMjA2NDY5MzIxMzM=