public function mayWrite() { if (strlen($this->_writeBuffer) > 4096) { $buff = substr($this->_writeBuffer, 0, 4096); $this->_writeBuffer = strlen($buff) > 0 ? substr($this->_writeBuffer, 4096) : ''; } else { $buff = $this->_writeBuffer; $this->_writeBuffer = ''; } if (WebSocketFunctions::writeWholeBuffer($this->_socket, $buff) == false) { $this->close(); } if (strlen($this->_writeBuffer) == 0 && $this->isClosing()) { $this->close(); } }