X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fliberalstomp.php;h=70c22c17e6a949ef7d72b749ce20c30dea0965a5;hb=a7b23fdb9d13c423de5407ddf2f360ac2de7c19c;hp=3d38953fd2cac9b3770673a06876bd9b3de7c5bd;hpb=779204b194447397d0770d96e291d9491fd731b9;p=quix0rs-gnu-social.git diff --git a/lib/liberalstomp.php b/lib/liberalstomp.php index 3d38953fd2..70c22c17e6 100644 --- a/lib/liberalstomp.php +++ b/lib/liberalstomp.php @@ -147,5 +147,30 @@ class LiberalStomp extends Stomp } return $frame; } -} + + /** + * Write frame to server + * + * @param StompFrame $stompFrame + */ + protected function _writeFrame (StompFrame $stompFrame) + { + if (!is_resource($this->_socket)) { + require_once 'Stomp/Exception.php'; + throw new StompException('Socket connection hasn\'t been established'); + } + + $data = $stompFrame->__toString(); + + // Make sure the socket's in a writable state; if not, wait a bit. + stream_set_blocking($this->_socket, 1); + + $r = fwrite($this->_socket, $data, strlen($data)); + stream_set_blocking($this->_socket, 0); + if ($r === false || $r == 0) { + $this->_reconnect(); + $this->_writeFrame($stompFrame); + } + } + }