12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- class StompFrame
- {
- public $command;
- public $headers = array();
- public $body;
-
-
- public function __construct ($command = null, $headers = null, $body = null)
- {
- $this->_init($command, $headers, $body);
- }
-
- protected function _init ($command = null, $headers = null, $body = null)
- {
- $this->command = $command;
- if ($headers != null) {
- $this->headers = $headers;
- }
- $this->body = $body;
-
- if ($this->command == 'ERROR') {
- require_once 'Exception.php';
- throw new StompException($this->headers['message'], 0, $this->body);
- }
- }
-
-
- public function __toString()
- {
- $data = $this->command . "\n";
-
- foreach ($this->headers as $name => $value) {
- $data .= $name . ": " . $value . "\n";
- }
-
- $data .= "\n";
- $data .= $this->body;
- return $data .= "\x00";
- }
- }
- ?>
|