/** * Test if has connection * * Remember that the sockets are lazy-initialised so we can create * connection instances to test with without incurring a socket connection. * * @param ConnectionInterface $connection * * @return boolean */ public function hasConnection(ConnectionInterface $connection) { return $this->find($connection->getSocket()) ? TRUE : FALSE; }
/** * Connection callback * * @param ConnectionInterface $connection */ public function connectionCallback(ConnectionInterface $connection) { if ($this->logger) { $this->logger->info("Connecting to " . (string) $connection . " and saying hello"); } $connection->write($this->writer->magic()); }
/** * Read and unpack string; reading $size bytes * * @param ConnectionInterface $connection * @param integer $size * * @return string */ private function readString(ConnectionInterface $connection, $size) { $temp = unpack("c{$size}chars", $connection->read($size)); $out = ""; foreach ($temp as $v) { if ($v > 0) { $out .= chr($v); } } return $out; }