+ /**
+ * Removes a given peer instance (socket) from all lists
+ *
+ * @param $peerInstance An instance of a HubPeer class
+ * @return void
+ */
+ private function removeSocket (HubPeer $peerInstance) {
+ // Get socket from peer
+ $socket = $peerInstance->getPeerSocket();
+
+ // Search for readers
+ $key = array_search($socket, $this->readPeers, true);
+ if ($key !== false) {
+ // Remove from reader list
+ unset($this->readPeers[$key]);
+ }
+
+ // Search for writers
+ $key = array_search($socket, $this->writePeers, true);
+ if ($key !== false) {
+ // Remove from writer list
+ unset($this->writePeers[$key]);
+ }
+
+ // Remove from auth peers as well
+ for ($idx = $this->authPeers->getIterator(); $idx->valid(); $idx->next()) {
+ // Get current entry
+ $current = $idx->current();
+
+ // Is it the same?
+ if ($current->equals($peerInstance)) {
+ // Remove from auth (-awaiting) list
+ $idx->offsetUnset($idx->key());
+ break;
+ }
+ }
+ }
+