connections = new \SplObjectStorage; $this->messageHistory = new \SplQueue; $this->errorHistory = new \SplQueue; } /** * {@inheritdoc} */ function onOpen(ConnectionInterface $conn) { $this->connections->attach($conn); } /** * {@inheritdoc} */ function onMessage(ConnectionInterface $from, $msg) { $this->messageHistory->enqueue(array('from' => $from, 'msg' => $msg)); } /** * {@inheritdoc} */ function onClose(ConnectionInterface $conn) { $this->connections->detach($conn); } /** * {@inheritdoc} */ function onError(ConnectionInterface $conn, \Exception $e) { $this->errorHistory->enqueue(array('conn' => $conn, 'exception' => $e)); } }