示例#1
0
 /**
  * @todo Bug: what if connect has been called twice. The first socket never
  *        gets closed.
  */
 public function disconnect()
 {
     if ($this->socket) {
         $this->socket->disconnect();
     }
     $this->connected = false;
 }
示例#2
0
 /**
  * Disconnects the underlying socket, and marks the client as disconnected
  *
  * @param int $reason Reason for disconnecting. See Protocol::CLOSE_*
  * @throws Exception\FrameException
  * @throws Exception\SocketException
  */
 public function disconnect($reason = Protocol::CLOSE_NORMAL)
 {
     $payload = $this->protocol->getClosePayload($reason);
     if ($this->socket) {
         $this->socket->send($payload->getPayload());
         $this->socket->disconnect();
     }
     $this->connected = false;
 }