diff options
author | Brion Vibber <brion@pobox.com> | 2010-06-11 12:04:03 -0700 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-06-11 12:04:03 -0700 |
commit | 47665e845ae74e6ee5b9a39565fb45dd9a93f921 (patch) | |
tree | a24680e60e250f085c7290c8fa0ecbc3ec4c6ea8 /lib/liberalstomp.php | |
parent | ec155464765db36591bbb183b335abbc1ec8638c (diff) | |
parent | 054ac909bf6222254cf9b2c3a4eda824f4f4eb8f (diff) |
Merge branch 'testing' of gitorious.org:statusnet/mainline into testing
Diffstat (limited to 'lib/liberalstomp.php')
-rw-r--r-- | lib/liberalstomp.php | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/lib/liberalstomp.php b/lib/liberalstomp.php index 3d38953fd..70c22c17e 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); + } + } + } |